Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

Add tests for resend signup email functionality

copilot-swe-agent[bot]22af7fbaec7d
diff --git a/app/actions/tenant.go b/app/actions/tenant.go
index 56ec30849..f9aeec544 100644
--- a/app/actions/tenant.go
+++ b/app/actions/tenant.go
@@ -120,8 +120,6 @@ func (action *CreateTenant) GetKind() enum.EmailVerificationKind {
// ResendSignUpEmail is the input model used to resend signup verification email
type ResendSignUpEmail struct {
VerificationKey string
- email string
- name string
}
func NewResendSignUpEmail() *ResendSignUpEmail {
@@ -135,10 +133,14 @@ func (action *ResendSignUpEmail) GetVerificationKey() string {
return action.VerificationKey
}
-// SetEmailAndName sets the email and name from the pending verification
-func (action *ResendSignUpEmail) SetEmailAndName(email, name string) {
- action.email = email
- action.name = name
+// GetEmail returns empty string (not used in this action)
+func (action *ResendSignUpEmail) GetEmail() string {
+ return ""
+}
+
+// GetName returns empty string (not used in this action)
+func (action *ResendSignUpEmail) GetName() string {
+ return ""
}
// IsAuthorized returns true if current user is authorized to perform this action
@@ -183,16 +185,6 @@ func (action *ResendSignUpEmail) Validate(ctx context.Context, user *entity.User
return result
}
-// GetEmail returns the email being verified
-func (action *ResendSignUpEmail) GetEmail() string {
- return action.email
-}
-
-// GetName returns the name of the email owner
-func (action *ResendSignUpEmail) GetName() string {
- return action.name
-}
-
// GetUser returns the current user performing this action
func (action *ResendSignUpEmail) GetUser() *entity.User {
return nil
diff --git a/app/handlers/signup.go b/app/handlers/signup.go
index 3ee16692e..dd84a05a7 100644
--- a/app/handlers/signup.go
+++ b/app/handlers/signup.go
@@ -220,7 +220,6 @@ func ResendSignUpEmail() web.HandlerFunc {
}
action := actions.NewResendSignUpEmail()
- action.SetEmailAndName(pendingVerification.Result.Email, pendingVerification.Result.Name)
if result := c.BindTo(action); !result.Ok {
return c.HandleValidation(result)
@@ -249,12 +248,38 @@ func ResendSignUpEmail() web.HandlerFunc {
// Send email
siteURL := web.TenantBaseURL(c, c.Tenant())
- c.Enqueue(tasks.SendSignUpEmail(action, siteURL))
+
+ // Create an adapter for the action to work with SendSignUpEmail
+ emailData := &resendEmailData{
+ verificationKey: action.VerificationKey,
+ email: pendingVerification.Result.Email,
+ name: pendingVerification.Result.Name,
+ }
+ c.Enqueue(tasks.SendSignUpEmail(emailData, siteURL))
return c.Ok(web.Map{})
}
}
+// resendEmailData implements SignUpEmailData interface
+type resendEmailData struct {
+ verificationKey string
+ email string
+ name string
+}
+
+func (r *resendEmailData) GetVerificationKey() string {
+ return r.verificationKey
+}
+
+func (r *resendEmailData) GetEmail() string {
+ return r.email
+}
+
+func (r *resendEmailData) GetName() string {
+ return r.name
+}
+
// resendEmailVerificationRequest is a helper struct for resending verification emails
type resendEmailVerificationRequest struct {
email string
diff --git a/app/handlers/signup_test.go b/app/handlers/signup_test.go
index e0a07540e..28cf9ac58 100644
--- a/app/handlers/signup_test.go
+++ b/app/handlers/signup_test.go
@@ -294,3 +294,89 @@ func TestCreateTenantHandler_WithEmailAndName(t *testing.T) {
Expect(saveKeyCmd.Request.GetEmail()).Equals("[email protected]")
Expect(saveKeyCmd.Request.GetName()).Equals("Jon Snow")
}
+
+func TestResendSignUpEmailHandler_NonPendingTenant(t *testing.T) {
+ RegisterT(t)
+
+ server := mock.NewServer()
+ code, _ := server.
+ OnTenant(mock.DemoTenant).
+ ExecutePost(handlers.ResendSignUpEmail(), `{}`)
+
+ Expect(code).Equals(http.StatusNotFound)
+}
+
+func TestResendSignUpEmailHandler_Success(t *testing.T) {
+ RegisterT(t)
+
+ // Setup pending tenant
+ pendingTenant := &entity.Tenant{
+ ID: 1,
+ Name: "Demo",
+ Subdomain: "demo",
+ Status: enum.TenantPending,
+ }
+
+ // Mock GetPendingSignUpVerification
+ bus.AddHandler(func(ctx context.Context, q *query.GetPendingSignUpVerification) error {
+ q.Result = &entity.EmailVerification{
+ Email: "[email protected]",
+ Name: "Jon Snow",
+ CreatedAt: time.Now().Add(-10 * time.Minute), // Old enough to allow resend
+ }
+ return nil
+ })
+
+ // Mock InvalidatePreviousSignUpKeys
+ bus.AddHandler(func(ctx context.Context, c *cmd.InvalidatePreviousSignUpKeys) error {
+ return nil
+ })
+
+ // Mock SaveVerificationKey
+ var saveKeyCmd *cmd.SaveVerificationKey
+ bus.AddHandler(func(ctx context.Context, c *cmd.SaveVerificationKey) error {
+ saveKeyCmd = c
+ return nil
+ })
+
+ server := mock.NewServer()
+ code, _ := server.
+ OnTenant(pendingTenant).
+ ExecutePost(handlers.ResendSignUpEmail(), `{}`)
+
+ Expect(code).Equals(http.StatusOK)
+ Expect(saveKeyCmd).IsNotNil()
+ Expect(saveKeyCmd.Key).HasLen(64)
+ Expect(saveKeyCmd.Request.GetEmail()).Equals("[email protected]")
+ Expect(saveKeyCmd.Request.GetName()).Equals("Jon Snow")
+}
+
+func TestResendSignUpEmailHandler_RateLimited(t *testing.T) {
+ RegisterT(t)
+
+ // Setup pending tenant
+ pendingTenant := &entity.Tenant{
+ ID: 1,
+ Name: "Demo",
+ Subdomain: "demo",
+ Status: enum.TenantPending,
+ }
+
+ // Mock GetPendingSignUpVerification with recent timestamp
+ bus.AddHandler(func(ctx context.Context, q *query.GetPendingSignUpVerification) error {
+ q.Result = &entity.EmailVerification{
+ Email: "[email protected]",
+ Name: "Jon Snow",
+ CreatedAt: time.Now().Add(-2 * time.Minute), // Too recent
+ }
+ return nil
+ })
+
+ server := mock.NewServer()
+ code, response := server.
+ OnTenant(pendingTenant).
+ ExecutePost(handlers.ResendSignUpEmail(), `{}`)
+
+ Expect(code).Equals(http.StatusBadRequest)
+ Expect(response.Body.String()).ContainsSubstring("Please wait")
+}
diff --git a/locale/ar/client.json b/locale/ar/client.json
index e170463e8..61d940c52 100644
--- a/locale/ar/client.json
+++ b/locale/ar/client.json
@@ -165,6 +165,9 @@
"page.backhome": "خذني إلى <0>{0}</0> الصفحة الرئيسية.",
"page.notinvited.text": "لم نتمكن من العثور على حساب لعنوان بريدك الإلكتروني.",
"page.notinvited.title": "لم تتم دعوتك",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "أرسلنا لك رسالة تأكيد بالبريد الإلكتروني مع رابط لتفعيل موقعك.",
"page.pendingactivation.text2": "الرجاء التحقق من صندوق الوارد الخاص بك لتفعيله.",
"page.pendingactivation.title": "حسابك في انتظار التفعيل",
diff --git a/locale/de/client.json b/locale/de/client.json
index aaf65fa79..083f181e3 100644
--- a/locale/de/client.json
+++ b/locale/de/client.json
@@ -165,6 +165,9 @@
"page.backhome": "Zurück zur <0>{0}</0> Homepage.",
"page.notinvited.text": "Wir konnten kein Account für deine E-Mail-Adresse finden.",
"page.notinvited.title": "Nicht eingeladen",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "Wir haben Ihnen eine Bestätigungs-E-Mail mit einem Link zur Aktivierung Ihrer Website geschickt.",
"page.pendingactivation.text2": "Bitte überprüfe deinen Posteingang, um ihn zu aktivieren.",
"page.pendingactivation.title": "Dein Account ist nicht aktiviert",
diff --git a/locale/el/client.json b/locale/el/client.json
index 95fc2d4a2..75876c2e0 100644
--- a/locale/el/client.json
+++ b/locale/el/client.json
@@ -165,6 +165,9 @@
"page.backhome": "Επιστρέψτε με στην αρχική σελίδα <0>{0}</0>.",
"page.notinvited.text": "Δεν μπορέσαμε να βρούμε λογαριασμό για τη διεύθυνση email σας.",
"page.notinvited.title": "Δεν έχει προσκληθεί",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "Σας στείλαμε ένα email επιβεβαίωσης με ένα σύνδεσμο για να ενεργοποιήσετε τον ιστότοπό σας.",
"page.pendingactivation.text2": "Παρακαλώ ελέγξτε τα εισερχόμενά σας για να το ενεργοποιήσετε.",
"page.pendingactivation.title": "Ο λογαριασμός σας εκκρεμεί ενεργοποίηση",
diff --git a/locale/en/client.json b/locale/en/client.json
index 20cc69c14..c7b347931 100644
--- a/locale/en/client.json
+++ b/locale/en/client.json
@@ -164,6 +164,9 @@
"page.backhome": "Take me back to <0>{0}</0> home page.",
"page.notinvited.text": "We could not find an account for your email address.",
"page.notinvited.title": "Not invited",
+ "page.pendingactivation.didntreceive": "Didn't receive the email?",
+ "page.pendingactivation.resend": "Resend verification email",
+ "page.pendingactivation.resending": "Resending...",
"page.pendingactivation.text": "We sent you a confirmation email with a link to activate your site.",
"page.pendingactivation.text2": "Please check your inbox to activate it.",
"page.pendingactivation.title": "Your account is pending activation",
@@ -200,8 +203,5 @@
"signin.message.socialbutton.intro": "Continue with",
"validation.custom.maxattachments": "A maximum of {number} attachments are allowed.",
"validation.custom.maximagesize": "The image size must be smaller than {kilobytes}KB.",
- "{count, plural, one {# tag} other {# tags}}": "{count, plural, one {# tag} other {# tags}}",
- "page.pendingactivation.didntreceive": "Didn't receive the email?",
- "page.pendingactivation.resend": "Resend verification email",
- "page.pendingactivation.resending": "Resending..."
+ "{count, plural, one {# tag} other {# tags}}": "{count, plural, one {# tag} other {# tags}}"
}
diff --git a/locale/es-ES/client.json b/locale/es-ES/client.json
index 3c3f9fa9a..844360bc2 100644
--- a/locale/es-ES/client.json
+++ b/locale/es-ES/client.json
@@ -165,6 +165,9 @@
"page.backhome": "Llévame a la página de inicio de <0>{0}</0>.",
"page.notinvited.text": "No pudimos encontrar una cuenta asociada a tu correo electrónico.",
"page.notinvited.title": "Sin invitación",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "Te hemos enviado un correo electrónico de confirmación con un enlace para activar tu sitio.",
"page.pendingactivation.text2": "Por favor, revisa tu bandeja de entrada para activarla.",
"page.pendingactivation.title": "Tu cuenta está pendiente de activación",
diff --git a/locale/fa/client.json b/locale/fa/client.json
index 49488b0b7..999d57b46 100644
--- a/locale/fa/client.json
+++ b/locale/fa/client.json
@@ -164,6 +164,9 @@
"page.backhome": "بازگشت به صفحهٔ اصلی <0>{0}</0>",
"page.notinvited.text": "ما حسابی برای آدرس ایمیل شما پیدا نکردیم.",
"page.notinvited.title": "دعوت نشده",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "یک ایمیل تأیید به شما ارسال کردیم.",
"page.pendingactivation.text2": "برای فعال‌سازی، صندوق ورودی خود را بررسی کنید.",
"page.pendingactivation.title": "حساب در انتظار فعال‌سازی",
diff --git a/locale/fr/client.json b/locale/fr/client.json
index b33145365..e317517d3 100644
--- a/locale/fr/client.json
+++ b/locale/fr/client.json
@@ -165,6 +165,9 @@
"page.backhome": "Ramenez-moi à la page d'accueil de <0>{0}</0>.",
"page.notinvited.text": "Nous n'avons pas trouvé de compte avec cette adresse e-mail.",
"page.notinvited.title": "Non invité",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "Nous vous avons envoyé un e-mail de confirmation avec un lien pour activer votre site.",
"page.pendingactivation.text2": "Veuillez vérifier votre boîte de réception pour l'activer.",
"page.pendingactivation.title": "Votre compte n'est pas activé",
diff --git a/locale/it/client.json b/locale/it/client.json
index dbd41d6e0..3bafc7ce4 100644
--- a/locale/it/client.json
+++ b/locale/it/client.json
@@ -165,6 +165,9 @@
"page.backhome": "Portami indietro alla <0>{0}</0> pagina principale.",
"page.notinvited.text": "Non siamo riusciti a trovare un account per il tuo indirizzo email.",
"page.notinvited.title": "Nessun invito",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "Vi abbiamo inviato un'e-mail di conferma con un link per attivare il vostro sito.",
"page.pendingactivation.text2": "Per favore controlla la tua casella e-mail per l’attivazione.",
"page.pendingactivation.title": "Il tuo account è in attesa di attivazione",
diff --git a/locale/ja/client.json b/locale/ja/client.json
index 515a13c9b..654a77836 100644
--- a/locale/ja/client.json
+++ b/locale/ja/client.json
@@ -165,6 +165,9 @@
"page.backhome": "<0>{0}</0>のホームページに戻ります。",
"page.notinvited.text": "あなたのメールアドレスのアカウントが見つかりませんでした",
"page.notinvited.title": "未招待",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "サイトを有効にするためのリンクが記載された確認メールを送信しました。",
"page.pendingactivation.text2": "受信トレイをチェックして有効化してください。",
"page.pendingactivation.title": "あなたのアカウントは認証待ちです。",
diff --git a/locale/nl/client.json b/locale/nl/client.json
index 0ff500273..0f9f15f0b 100644
--- a/locale/nl/client.json
+++ b/locale/nl/client.json
@@ -165,6 +165,9 @@
"page.backhome": "Ga terug naar <0>{0}</0> startpagina.",
"page.notinvited.text": "We konden geen account vinden voor dit e-mailadres.",
"page.notinvited.title": "Niet uitgenodigd",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "We hebben je een bevestigingsmail gestuurd met een link om jouw site te activeren.",
"page.pendingactivation.text2": "Controleer je inbox om het te activeren.",
"page.pendingactivation.title": "Je account is nog niet geactiveerd",
diff --git a/locale/pl/client.json b/locale/pl/client.json
index 42fdf2b3e..94fbdf15a 100644
--- a/locale/pl/client.json
+++ b/locale/pl/client.json
@@ -165,6 +165,9 @@
"page.backhome": "Zabierz mnie z powrotem na stronę główną <0>{0}</0>.",
"page.notinvited.text": "Nie znaleźliśmy konta powiązanego z Twoim adresem email.",
"page.notinvited.title": "Niezaproszony",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "Wysłaliśmy do Ciebie maila z linkiem do aktywowania Twojej strony.",
"page.pendingactivation.text2": "Sprawdź swoją skrzynkę odbiorczą, aby ją aktywować.",
"page.pendingactivation.title": "Twoje konto oczekuje na aktywację",
diff --git a/locale/pt-BR/client.json b/locale/pt-BR/client.json
index 012ebe2ad..d93ba9318 100644
--- a/locale/pt-BR/client.json
+++ b/locale/pt-BR/client.json
@@ -165,6 +165,9 @@
"page.backhome": "Me leve de volta para a página inicial <0>{0}</0>.",
"page.notinvited.text": "Não encontramos nenhuma conta para o seu endereço de e-mail.",
"page.notinvited.title": "Sem convite",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "Enviamos a você um e-mail de confirmação com um link para ativar o seu site.",
"page.pendingactivation.text2": "Verifique sua caixa de entrada para ativá-la.",
"page.pendingactivation.title": "Sua conta está com ativação pendente",
diff --git a/locale/ru/client.json b/locale/ru/client.json
index 8c4a3fc5b..17634ecc8 100644
--- a/locale/ru/client.json
+++ b/locale/ru/client.json
@@ -165,6 +165,9 @@
"page.backhome": "Верните меня на домашнюю страницу <0>{0}</0>.",
"page.notinvited.text": "Мы не смогли найти аккаунт, соответствующий этому адресу электронной почты.",
"page.notinvited.title": "Не приглашён",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "Мы отправили вам письмо со ссылкой для активации этого сайта.",
"page.pendingactivation.text2": "Проверьте свою почту, чтобы продолжить.",
"page.pendingactivation.title": "Ваш аккаунт ожидает подтверждения",
diff --git a/locale/sk/client.json b/locale/sk/client.json
index 21c5219ac..a18ae8fe6 100644
--- a/locale/sk/client.json
+++ b/locale/sk/client.json
@@ -165,6 +165,9 @@
"page.backhome": "Vezmi ma späť do <0>{0}</0> domovskú stránku.",
"page.notinvited.text": "Nepodarilo sa nám nájsť účet pre vašu emailovú adresu.",
"page.notinvited.title": "Nepozvaný",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "Poslali sme vám potvrdzovací email s odkazom na aktiváciu vašich stránok.",
"page.pendingactivation.text2": "Aktivujte prosím svoju doručenú poštu.",
"page.pendingactivation.title": "Váš účet čaká na aktiváciu",
diff --git a/locale/sv-SE/client.json b/locale/sv-SE/client.json
index 1c0884a6d..cda7dae03 100644
--- a/locale/sv-SE/client.json
+++ b/locale/sv-SE/client.json
@@ -165,6 +165,9 @@
"page.backhome": "Ta mig tillbaka till <0>{0}</0> hemsida.",
"page.notinvited.text": "Vi kunde inte hitta ett konto för din e-postadress.",
"page.notinvited.title": "Inte inbjuden",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "Vi har skickat ett bekräftelsemail med en länk för att aktivera din webbplats.",
"page.pendingactivation.text2": "Kontrollera din inkorg för att aktivera den.",
"page.pendingactivation.title": "Ditt konto väntar på aktivering",
diff --git a/locale/tr/client.json b/locale/tr/client.json
index bece7995e..184f1346a 100644
--- a/locale/tr/client.json
+++ b/locale/tr/client.json
@@ -165,6 +165,9 @@
"page.backhome": "Beni <0>{0}</0> ana sayfaya götür.",
"page.notinvited.text": "E-posta adresinizle ilişkili bir hesap bulamadık.",
"page.notinvited.title": "Davet edilmemiş",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "Size, sayfanız için aktivasyon bağlantısı barındıran bir onay e-postası gönderdik.",
"page.pendingactivation.text2": "Aktivasyon için lütfen gelen kutunuzu kontrol edin.",
"page.pendingactivation.title": "Hesabınız aktivasyon beklemektedir",
diff --git a/locale/zh-CN/client.json b/locale/zh-CN/client.json
index 028e607a9..3173b260f 100644
--- a/locale/zh-CN/client.json
+++ b/locale/zh-CN/client.json
@@ -165,6 +165,9 @@
"page.backhome": "带我回到<0>{0}</0>主页.",
"page.notinvited.text": "我们找不到您电子邮件地址的帐户.",
"page.notinvited.title": "未被邀请",
+ "page.pendingactivation.didntreceive": "",
+ "page.pendingactivation.resend": "",
+ "page.pendingactivation.resending": "",
"page.pendingactivation.text": "我们向您发送了一封确认电子邮件,其中包含激活您账户的网站链接.",
"page.pendingactivation.text2": "请检查您的收件箱以激活它.",
"page.pendingactivation.title": "您的帐户正在等待激活",