diff --git a/src/app/components/login/forgot-pw/forgot-pw.component.html b/src/app/components/login/forgot-pw/forgot-pw.component.html
index 50460ce..6b7d8ee 100644
--- a/src/app/components/login/forgot-pw/forgot-pw.component.html
+++ b/src/app/components/login/forgot-pw/forgot-pw.component.html
@@ -38,10 +38,10 @@
}
@if(!mail.valid && mail.touched &&
- !checkIfUserEmailIsValid(pwResetData.mail.toLowerCase())) {
+ !isEmailValid(pwResetData.mail.toLowerCase())) {
{{ "register.errorMail0" | translate }}
} @else { @if (mail.touched &&
- !checkIfUserEmailIsValid(pwResetData.mail.toLowerCase())) {
+ !isEmailValid(pwResetData.mail.toLowerCase())) {
{{ "register.errorMail1" | translate }}
} }
@@ -58,7 +58,7 @@
mail.invalid ||
!pwResetData.mail ||
isButtonDisabled() ||
- !checkIfUserEmailIsValid(pwResetData.mail)
+ !isEmailValid(pwResetData.mail)
"
>
diff --git a/src/app/components/login/forgot-pw/forgot-pw.component.ts b/src/app/components/login/forgot-pw/forgot-pw.component.ts
index d23cc90..28bc17e 100644
--- a/src/app/components/login/forgot-pw/forgot-pw.component.ts
+++ b/src/app/components/login/forgot-pw/forgot-pw.component.ts
@@ -5,9 +5,9 @@ import { FormBtnComponent } from '../../../shared/components/buttons/form-btn/fo
import { FooterComponent } from '../footer/footer.component';
import { HeaderComponent } from '../header/header.component';
import { TranslateModule } from '@ngx-translate/core';
-import { LoginService } from '../../../services/login.service';
import { BtnBackComponent } from '../../../shared/components/buttons/btn-back/btn-back.component';
import { ButtonStateService } from '../../../services/button-state.service';
+import { AuthService } from '../../../services/auth.service';
@Component({
selector: 'app-forgot-pw',
@@ -30,14 +30,14 @@ export class ForgotPwComponent {
};
constructor(
- public loginService: LoginService,
- private buttonStateService: ButtonStateService
+ private buttonStateService: ButtonStateService,
+ private authService: AuthService
) {}
onSubmit(ngForm: NgForm) {
this.buttonStateService.enableButton();
if (ngForm.submitted && ngForm.form.valid) {
- this.loginService.passwordReset(this.pwResetData.mail.toLowerCase());
+ this.authService.resetPassword(this.pwResetData.mail.toLowerCase());
}
}
@@ -45,7 +45,7 @@ export class ForgotPwComponent {
return this.buttonStateService.isButtonDisabled;
}
- checkIfUserEmailIsValid(emailValue: string) {
+ isEmailValid(emailValue: string) {
const emailRegex = /^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,}$/;
if (emailRegex.test(emailValue)) {
return true;
diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts
index 83edad5..d1c9b1c 100755
--- a/src/app/services/auth.service.ts
+++ b/src/app/services/auth.service.ts
@@ -73,6 +73,17 @@ export class AuthService {
}
}
+ async resetPassword(email: string): Promise {
+ try {
+ await lastValueFrom(
+ this.apiService.request('POST', `/auth/reset/`, { email })
+ );
+ this.toastNotificationService.resetPasswordSuccessToast();
+ } catch (error) {
+ console.error('Password reset failed:', error);
+ }
+ }
+
checkAuthUser(): Observable {
return this.apiService.request('GET', `/auth/`).pipe(
map(() => true),
diff --git a/src/app/services/toast-notification.service.ts b/src/app/services/toast-notification.service.ts
index 5080a7f..3536305 100755
--- a/src/app/services/toast-notification.service.ts
+++ b/src/app/services/toast-notification.service.ts
@@ -29,6 +29,13 @@ export class ToastNotificationService {
);
}
+ resetPasswordSuccessToast(): void {
+ this.createSuccessToast(
+ 'If the e-mail address is valid, you will receive an e-mail with a link to reset the password.',
+ 'Password Reset Successful'
+ );
+ }
+
showSessionExpiredMessage(): void {
this.createInfoToast(
'Your session has expired, please log in again.',