mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
fix: comparing verificationCode hashes
This commit is contained in:
@@ -2,6 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/go-chi/jwtauth/v5"
|
"github.com/go-chi/jwtauth/v5"
|
||||||
|
"golang.org/x/crypto/bcrypt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -19,7 +20,8 @@ func GetRegisterValidatePage(w http.ResponseWriter, r *http.Request) {
|
|||||||
user, _ := Container.GetUserUseCase.GetUser(userId)
|
user, _ := Container.GetUserUseCase.GetUser(userId)
|
||||||
errorMessage := ""
|
errorMessage := ""
|
||||||
|
|
||||||
if user.VerificationCode != queryVerificationCode || user.VerificationExpiration.Before(time.Now()) {
|
err := bcrypt.CompareHashAndPassword([]byte(user.VerificationCode), []byte(queryVerificationCode))
|
||||||
|
if err != nil || user.VerificationExpiration.Before(time.Now()) {
|
||||||
errorMessage = "Verification link is incorrect or has expired."
|
errorMessage = "Verification link is incorrect or has expired."
|
||||||
} else {
|
} else {
|
||||||
// TODO New usecase "UpdateUserUseCase" to update its verification status
|
// TODO New usecase "UpdateUserUseCase" to update its verification status
|
||||||
|
|||||||
Reference in New Issue
Block a user