fix(auth): remove commented out code

This commit is contained in:
2024-09-11 16:17:23 +02:00
parent 80ab17276e
commit eb95757d1c

View File

@@ -12,22 +12,13 @@ func EnsureValidSession(db *sql.DB, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// handled, redirected := handleSignInAndOutRoutes(db, w, r)
// if handled {
// if !redirected {
// next.ServeHTTP(w, r)
// }
//
// return
// }
user := utils.GetUserFromSession(db, r)
if user == nil {
utils.DoRedirect(w, r, "/auth/signin")
return
}
if r.URL.Path != "/auth/verify" && !user.EmailVerified {
if !user.EmailVerified && r.URL.Path != "/auth/verify" {
utils.DoRedirect(w, r, "/auth/verify")
return
}
@@ -37,23 +28,3 @@ func EnsureValidSession(db *sql.DB, next http.Handler) http.Handler {
next.ServeHTTP(w, r.WithContext(ctx))
})
}
// func handleSignInAndOutRoutes(db *sql.DB, w http.ResponseWriter, r *http.Request) (bool, bool) {
// if r.URL.Path != "/auth/signin" && r.URL.Path != "/auth/signup" && r.URL.Path != "/api/auth/verify-resend" {
// return false, false
// }
//
// sessionId := getSessionID(r)
// user := verifySession(db, sessionId)
// if user == nil {
// return true, false
// }
//
// if user.EmailVerified {
// utils.DoRedirect(w, r, "/")
// } else {
// utils.DoRedirect(w, r, "/auth/verify")
// }
//
// return true, true
// }