diff options
| author | haturatu <taro@eyes4you.org> | 2025-10-13 06:19:50 +0900 |
|---|---|---|
| committer | haturatu <taro@eyes4you.org> | 2025-10-13 06:19:50 +0900 |
| commit | 18991704b375db4e8d22785bb47f3e2e12cd016f (patch) | |
| tree | 147c12163efbf1a51b38ce4b4bffbaf15dc1dc01 /handlers | |
| parent | a4a5b418e367c3172439c080490cd5b3dfb526c1 (diff) | |
chore(auth): loginned redirect login -> account
Diffstat (limited to 'handlers')
| -rw-r--r-- | handlers/auth_login.go | 10 |
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, |
