Redirect from /login to /admin if user is already logged in

This commit is contained in:
jordi fita mas 2023-08-06 03:59:52 +02:00
parent e128680e9a
commit 1456ac5341
1 changed files with 5 additions and 1 deletions

View File

@ -89,7 +89,11 @@ func (h *App) ServeHTTP(w http.ResponseWriter, r *http.Request) {
case "login": case "login":
switch r.Method { switch r.Method {
case http.MethodGet: case http.MethodGet:
serveLoginForm(w, r, user, company, "/admin") if user.LoggedIn {
httplib.Redirect(w, r, "/admin", http.StatusFound)
} else {
serveLoginForm(w, r, user, company, "/admin")
}
case http.MethodPost: case http.MethodPost:
handleLogin(w, r, user, company, conn) handleLogin(w, r, user, company, conn)
default: default: