diff --git a/frontend/src/app/pages/welcome-root/welcome-root.component.ts b/frontend/src/app/pages/welcome-root/welcome-root.component.ts index 9e8ba53..a864200 100644 --- a/frontend/src/app/pages/welcome-root/welcome-root.component.ts +++ b/frontend/src/app/pages/welcome-root/welcome-root.component.ts @@ -42,6 +42,8 @@ import { } from '../../shared/service'; import { customEmailValidator } from '../../shared/validator'; +import { LocalStorageService } from './../../shared/service/local-storage.service'; + @Component({ selector: 'app-unified-login', standalone: true, @@ -98,11 +100,12 @@ export class WelcomeRootComponent implements OnInit { private readonly router: Router, private readonly themeService: ThemeService, private readonly el: ElementRef, - private readonly backgroundPatternService: BackgroundPatternService + private readonly backgroundPatternService: BackgroundPatternService, + private readonly localStorageService: LocalStorageService ) { effect(() => { if (this.removeQueryParams()) { - //this.clearRouteParams(); + this.clearRouteParams(); } }); } @@ -111,6 +114,7 @@ export class WelcomeRootComponent implements OnInit { this.autologin(); this.setBackground(); this.initializeForm(); + this.prefillEmail(); this.verifySignupMagicLink(); this.verifySigninMagicLink(); } @@ -260,10 +264,11 @@ export class WelcomeRootComponent implements OnInit { const email: string = this.extractEmail(); const decodedEmail: string = decodeURIComponent(atob(email)); + this.removeQueryParams.set(true); + if (token && email) { if (isSignup) { this.setupEmailField(decodedEmail); - this.removeQueryParams.set(true); this.addPasswordFieldToForm(); this.isRegistrationMode.set(true); } @@ -421,11 +426,24 @@ export class WelcomeRootComponent implements OnInit { ) .subscribe((response: SuccessDtoApiModel) => { if (response.success) { + this.remeberUserMail(signupCredentials.email); // Display Modal // You have successfully signed up. Please check your email for the magic link. } }); } + private prefillEmail(): void { + const email = this.localStorageService.getItem('email'); + + if (email) { + this.form.get('email')?.setValue(email); + } + } + + private remeberUserMail(email: string): void { + this.localStorageService.setItem('email', email); + } + private sendLoginEmail(email: string): void { this.isLoading.set(true); const magiclink: MagicLinkDtoApiModel = { @@ -442,6 +460,7 @@ export class WelcomeRootComponent implements OnInit { .subscribe((response: SuccessDtoApiModel) => { if (response.success) { this.isEmailSent.set(true); + this.remeberUserMail(email); } }); }