add another check before generating a token for the used email

This commit is contained in:
2026-01-06 09:19:15 +08:00
parent 4068992e06
commit c8e873cbc1
+7 -1
View File
@@ -228,7 +228,13 @@ func GoogleCallback(w http.ResponseWriter, r *http.Request) {
helper.RespondWithError(w, http.StatusBadGateway, "Error checking email in database")
return
}
helper.LogError(fmt.Errorf("%v", emailExists), "Email exists in DB")
if !emailExists {
helper.LogError(errors.New("email not found"), "Email not registered: "+email)
helper.RespondWithError(w, http.StatusUnauthorized, "Email not registered. Please contact the administrator.")
return
}
accessToken, refreshToken, err := GenerateTokens(email, userAgent, ipAddress)
if err != nil {
helper.LogError(err, "Error generating access token")