summaryrefslogtreecommitdiff
path: root/handlers/auth_login.go
diff options
context:
space:
mode:
Diffstat (limited to 'handlers/auth_login.go')
-rw-r--r--handlers/auth_login.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/handlers/auth_login.go b/handlers/auth_login.go
index 855fa8a..5621dcb 100644
--- a/handlers/auth_login.go
+++ b/handlers/auth_login.go
@@ -100,6 +100,16 @@ func renderLoginWithError(w http.ResponseWriter, r *http.Request, message string
func LoginHandler(w http.ResponseWriter, r *http.Request) {
ip := logging.GetClientIP(r)
+ // If user is already logged in, redirect to account page
+ cookie, err := r.Cookie("auth_token")
+ if err == nil {
+ user, _ := models.GetUserByToken(cookie.Value)
+ if user != nil {
+ http.Redirect(w, r, config.Paths.Account, http.StatusFound)
+ return
+ }
+ }
+
if r.Method == http.MethodGet {
data := map[string]interface{}{
"Paths": config.Paths,