Password reset & user lookup API

This commit is contained in:
2024-06-30 17:20:05 +08:00
parent e5d8f1ab3b
commit a4ccf12b7a
6 changed files with 71 additions and 41 deletions

View File

@@ -141,10 +141,11 @@ func CheckAbleToResetPassword(user models.Account) error {
if err := database.C.
Where("account_id = ?", user.ID).
Where("expired_at < ?", time.Now()).
Where("type = ?", models.ResetPasswordMagicToken).
Model(&models.MagicToken{}).
Count(&count).Error; err != nil {
return fmt.Errorf("unable to check reset password ability: %v", err)
} else if count == 0 {
} else if count > 0 {
return fmt.Errorf("you requested reset password recently")
}