diff --git a/backend/src/Socialize.Api/Modules/Identity/Handlers/Register.cs b/backend/src/Socialize.Api/Modules/Identity/Handlers/Register.cs index b6f51ad..316cb1f 100644 --- a/backend/src/Socialize.Api/Modules/Identity/Handlers/Register.cs +++ b/backend/src/Socialize.Api/Modules/Identity/Handlers/Register.cs @@ -32,10 +32,18 @@ public class RegisterHandler( RegisterRequest request, CancellationToken ct) { - // Check if the user already exists User? existingUser = await userManager.FindByEmailAsync(request.Email); if (existingUser is not null) { + if (!existingUser.EmailConfirmed) + { + await emailVerificationService.SendVerificationEmailAsync(existingUser); + await SendOkAsync( + new RegisterResponse("Registration successful! Please check your email to verify your account."), + ct); + return; + } + await SendStringAsync( "A user with this email already exists", 400, diff --git a/frontend/src/features/auth/views/LoginView.vue b/frontend/src/features/auth/views/LoginView.vue index 52f7704..0218e11 100644 --- a/frontend/src/features/auth/views/LoginView.vue +++ b/frontend/src/features/auth/views/LoginView.vue @@ -198,7 +198,10 @@ } function resendVerification() { - router.push('/verify-email'); + router.push({ + path: '/verify-email', + query: email.value ? { email: email.value.trim() } : {}, + }); } diff --git a/frontend/src/features/auth/views/RegisterView.vue b/frontend/src/features/auth/views/RegisterView.vue index ae2a6f9..0e3dfaf 100644 --- a/frontend/src/features/auth/views/RegisterView.vue +++ b/frontend/src/features/auth/views/RegisterView.vue @@ -135,10 +135,12 @@ import { ref } from 'vue'; import { useClient } from '@/plugins/api.js'; import { useI18n } from 'vue-i18n'; + import { useRouter } from 'vue-router'; import { mdiEye, mdiEyeOff } from '@mdi/js'; import { branding } from '@/branding/branding.js'; const { t } = useI18n(); + const router = useRouter(); const clientApi = useClient(); const name = ref(''); @@ -168,9 +170,12 @@ password: password.value, }); - // On success, show verification message userEmail.value = email.value.trim(); registrationSuccess.value = true; + await router.push({ + path: '/verify-email', + query: { email: userEmail.value, pending: '1' }, + }); } catch (error) { console.error('Registration failed:', error); errorMessage.value = error.response?.data?.message || t('registrationFailed'); diff --git a/frontend/src/features/auth/views/VerifyEmailView.vue b/frontend/src/features/auth/views/VerifyEmailView.vue index ef60c29..5ab8444 100644 --- a/frontend/src/features/auth/views/VerifyEmailView.vue +++ b/frontend/src/features/auth/views/VerifyEmailView.vue @@ -36,28 +36,18 @@
-

{{ t('error.title') }}

-

{{ errorMessage || t('error.defaultMessage') }}

+

{{ t('pending.title') }}

+

{{ t('pending.message') }}

- - {{ t('error.goToLogin') }} - - - - -

{{ t('resend.title') }}

+ + +
+ +

{{ t('error.title') }}

+

{{ errorMessage || t('error.defaultMessage') }}

+ +
+ + {{ t('error.goToLogin') }} + + + +

{{ t('resend.title') }}

+ +
+ + + + {{ t('resend.button') }} + + +
+ {{ t('resend.success') }} +
+ +
+ {{ resendError }} +
+
+
+
+
@@ -118,6 +171,7 @@ const isLoading = ref(true); const verificationSuccess = ref(false); const errorMessage = ref(''); + const showResendOnly = ref(false); // Resend verification state const resendEmail = ref(''); @@ -138,7 +192,11 @@ // Check if we have the required parameters if (!userId || !token) { isLoading.value = false; - errorMessage.value = t('error.missingParams'); + if (route.query.email || route.query.pending) { + showResendOnly.value = true; + } else { + errorMessage.value = t('error.missingParams'); + } return; } @@ -202,8 +260,13 @@ "missingParams": "Missing required verification parameters.", "goToLogin": "Go to Login" }, + "pending": { + "title": "Check your email", + "message": "We sent a verification link to your inbox. You can request a new link if it doesn't arrive." + }, "resend": { "title": "Resend Verification Email", + "description": "Enter your account email and we'll send a new verification link.", "emailLabel": "Email", "button": "Resend Verification Email", "success": "Verification email sent successfully. Please check your inbox.", @@ -224,8 +287,13 @@ "missingParams": "Paramètres de vérification requis manquants.", "goToLogin": "Aller à la connexion" }, + "pending": { + "title": "Vérifiez votre email", + "message": "Nous avons envoyé un lien de vérification dans votre boîte de réception. Vous pouvez demander un nouveau lien s'il n'arrive pas." + }, "resend": { "title": "Renvoyer l'email de vérification", + "description": "Entrez l'email de votre compte et nous enverrons un nouveau lien de vérification.", "emailLabel": "Email", "button": "Renvoyer l'email de vérification", "success": "Email de vérification envoyé avec succès. Veuillez vérifier votre boîte de réception.",