Add an API to reset the password

This commit is contained in:
Nikolai Rodionov 2024-05-22 09:55:10 +02:00
parent f4707b295f
commit a631d5dbfc
Signed by: allanger
GPG Key ID: 0AA46A90E25592AD

View File

@ -244,8 +244,13 @@ func (acc *Account) ResetPassword(ctx context.Context, emailConfig email.EmailCo
} else if k8serrors.IsAlreadyExists(err) { } else if k8serrors.IsAlreadyExists(err) {
timestamp := sec.CreationTimestamp.Time timestamp := sec.CreationTimestamp.Time
now := time.Now() now := time.Now()
if timestamp.Add(time.Minute).Before(now) { if timestamp.Add(time.Minute).After(now) {
return "", errors.New("You can send an email once per minute, please wait") return "", errors.New("you can send an email once per minute, please wait")
}
_, err := clientset.CoreV1().Secrets(acc.Data.UUID).Update(ctx, &secret, metav1.UpdateOptions{})
if err != nil {
return "", err
} }
} }