this repo has no description

return to / if already logged in at /login

Changed files
+14 -4
legit
+7
legit/routes/auth.go
··· 20 20 auth, ok := session.Values["authenticated"].(bool) 21 21 22 22 if !ok || !auth { 23 + log.Printf("not logged in, redirecting") 23 24 http.Redirect(w, r, "/login", http.StatusTemporaryRedirect) 24 25 return 25 26 } ··· 58 59 } 59 60 60 61 log.Println("successfully refreshed token") 62 + } 63 + 64 + if r.URL.Path == "/login" { 65 + log.Println("already logged in") 66 + http.Redirect(w, r, "/", http.StatusTemporaryRedirect) 67 + return 61 68 } 62 69 63 70 next.ServeHTTP(w, r)
+5 -2
legit/routes/handler.go
··· 60 60 auth: auth, 61 61 } 62 62 63 - r.Get("/login", h.Login) 64 - r.Post("/login", h.Login) 63 + r.Group(func(r chi.Router) { 64 + r.Use(h.AuthMiddleware) 65 + r.Get("/login", h.Login) 66 + r.Post("/login", h.Login) 67 + }) 65 68 r.Get("/static/{file}", h.ServeStatic) 66 69 67 70 r.Route("/repo", func(r chi.Router) {
+2 -2
legit/routes/routes.go
··· 463 463 } 464 464 465 465 log.Printf("successfully saved session for %s (%s)", atSession.Handle, atSession.Did) 466 - w.Header().Set("HX-Redirect", "/") 467 - w.WriteHeader(http.StatusOK) 466 + http.Redirect(w, r, "/", http.StatusPermanentRedirect) 467 + return 468 468 } 469 469 } 470 470