feat: WIP mail verification flow

This commit is contained in:
Florian Sylvain
2024-05-14 19:37:44 +02:00
parent 8015639db5
commit ec14eee439
22 changed files with 265 additions and 143 deletions
+17 -1
View File
@@ -47,6 +47,16 @@ func IsLoggedInMiddleware(next http.Handler) http.Handler {
})
}
func IsVerifiedMiddleware(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)
}
@@ -91,7 +101,13 @@ func NewPageRouter() http.Handler {
r.Group(func(r chi.Router) {
r.Use(IsLoggedInMiddleware)
r.Get("/register-confirm", GetRegisterConfirmPage)
r.Get("/register/pending", GetRegisterPendingPage)
r.Get("/register/validate", GetRegisterValidatePage)
})
r.Group(func(r chi.Router) {
r.Use(IsLoggedInMiddleware)
r.Use(IsVerifiedMiddleware)
r.Get("/home", GetHomePage)
r.Get("/post", GetPostsPage)
r.Get("/post/edit", GetPostEditPage)