feat: email verification flow (not 100% complete)

This commit is contained in:
Florian Sylvain
2024-05-15 12:04:30 +02:00
parent 37647e60d9
commit c929acd4ab
11 changed files with 126 additions and 24 deletions
+11
View File
@@ -57,6 +57,16 @@ func IsVerifiedMiddleware(next http.Handler) http.Handler {
})
}
func IsNotVerifiedMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if IsVerified(r) {
http.Redirect(w, r, "/register/pending", http.StatusSeeOther)
return
}
next.ServeHTTP(w, r)
})
}
func GetLogin(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, LoginRoute, http.StatusPermanentRedirect)
}
@@ -101,6 +111,7 @@ func NewPageRouter() http.Handler {
r.Group(func(r chi.Router) {
r.Use(IsLoggedInMiddleware)
r.Use(IsNotVerifiedMiddleware)
r.Get("/register/pending", GetRegisterPendingPage)
r.Get("/register/validate", GetRegisterValidatePage)
})