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 -3
View File
@@ -63,9 +63,17 @@ func IsLoggedIn(r *http.Request) bool {
}
func IsVerified(r *http.Request) bool {
_, claims, _ := jwtauth.FromContext(r.Context())
userIDClaim, _ := claims["user_id"].(uint32)
currentUser, _ := Container.GetUserUseCase.GetUser(userIDClaim)
token, err := jwtauth.VerifyRequest(
TokenAuth,
r,
jwtauth.TokenFromCookie,
jwtauth.TokenFromHeader,
jwtauth.TokenFromQuery)
if err != nil {
return false
}
userId := token.PrivateClaims()["user_id"].(float64)
currentUser, _ := Container.GetUserUseCase.GetUser(uint32(userId))
return currentUser.IsVerified
}