From a631d5dbfc06fb5217b9dbcec7473ca06e353a74 Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Wed, 22 May 2024 09:55:10 +0200 Subject: [PATCH] Add an API to reset the password --- internal/controllers/accounts.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/controllers/accounts.go b/internal/controllers/accounts.go index 3d7a36c..02e28a5 100644 --- a/internal/controllers/accounts.go +++ b/internal/controllers/accounts.go @@ -244,8 +244,13 @@ func (acc *Account) ResetPassword(ctx context.Context, emailConfig email.EmailCo } else if k8serrors.IsAlreadyExists(err) { timestamp := sec.CreationTimestamp.Time now := time.Now() - if timestamp.Add(time.Minute).Before(now) { - return "", errors.New("You can send an email once per minute, please wait") + if timestamp.Add(time.Minute).After(now) { + 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 } }