fix(auth): remove commented out code
This commit is contained in:
@@ -12,22 +12,13 @@ func EnsureValidSession(db *sql.DB, next http.Handler) http.Handler {
|
|||||||
|
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
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)
|
user := utils.GetUserFromSession(db, r)
|
||||||
if user == nil {
|
if user == nil {
|
||||||
utils.DoRedirect(w, r, "/auth/signin")
|
utils.DoRedirect(w, r, "/auth/signin")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.URL.Path != "/auth/verify" && !user.EmailVerified {
|
if !user.EmailVerified && r.URL.Path != "/auth/verify" {
|
||||||
utils.DoRedirect(w, r, "/auth/verify")
|
utils.DoRedirect(w, r, "/auth/verify")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -37,23 +28,3 @@ func EnsureValidSession(db *sql.DB, next http.Handler) http.Handler {
|
|||||||
next.ServeHTTP(w, r.WithContext(ctx))
|
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
|
|
||||||
// }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user