From ee324c1f288298cf28d5066f8b93969ad3204b3c Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Wed, 8 Aug 2018 11:38:16 +0530 Subject: [PATCH] login, signup: redirect to dashboard if logged in Fixes https://gitlab.com/commento/commento-ce/issues/60 --- frontend/js/auth-common.js | 9 +++++++++ frontend/login.html | 1 + frontend/signup.html | 1 + 3 files changed, 11 insertions(+) diff --git a/frontend/js/auth-common.js b/frontend/js/auth-common.js index 9fe2b02..94dcdd3 100644 --- a/frontend/js/auth-common.js +++ b/frontend/js/auth-common.js @@ -1,5 +1,14 @@ (function (global, document) { + // Redirect the user to the dashboard if there's a cookie. If the cookie is + // invalid, they would be redirected back to the login page *after* the + // cookie is deleted. + global.loggedInRedirect = function() { + if (global.cookieGet("commentoOwnerToken") !== undefined) + document.location = "/dashboard"; + } + + // Prefills the email field from the URL parameter. global.prefillEmail = function() { if (paramGet("email") != undefined) { diff --git a/frontend/login.html b/frontend/login.html index c18076f..b19e76e 100644 --- a/frontend/login.html +++ b/frontend/login.html @@ -16,6 +16,7 @@