feat(auth): add recover password functionality and forms
Some checks failed
CI / Get Changed Files (pull_request) Successful in 8s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Has been skipped
CI / oxlint (pull_request) Successful in 19s
CI / eslint (pull_request) Successful in 28s
CI / prettier (pull_request) Failing after 26s
CI / test-build (pull_request) Successful in 42s
CI / Docker frontend validation (pull_request) Successful in 48s
Some checks failed
CI / Get Changed Files (pull_request) Successful in 8s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Has been skipped
CI / oxlint (pull_request) Successful in 19s
CI / eslint (pull_request) Successful in 28s
CI / prettier (pull_request) Failing after 26s
CI / test-build (pull_request) Successful in 42s
CI / Docker frontend validation (pull_request) Successful in 48s
This commit is contained in:
parent
7d471b6898
commit
9a95ad3d0f
5 changed files with 212 additions and 176 deletions
|
@ -1,16 +1,16 @@
|
|||
import { Component, EventEmitter, Output, signal } from '@angular/core';
|
||||
import { Component, EventEmitter, Output, signal, OnInit } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { AuthService } from '@service/auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-recover-password',
|
||||
standalone: true,
|
||||
imports: [CommonModule, ReactiveFormsModule],
|
||||
imports: [CommonModule, ReactiveFormsModule, RouterModule],
|
||||
templateUrl: './recover-password.component.html',
|
||||
})
|
||||
export class RecoverPasswordComponent {
|
||||
export class RecoverPasswordComponent implements OnInit {
|
||||
emailForm: FormGroup;
|
||||
resetPasswordForm: FormGroup;
|
||||
errorMessage = signal('');
|
||||
|
@ -20,6 +20,7 @@ export class RecoverPasswordComponent {
|
|||
isResetMode = signal(false);
|
||||
|
||||
@Output() closeDialog = new EventEmitter<void>();
|
||||
@Output() switchToLogin = new EventEmitter<void>();
|
||||
|
||||
constructor(
|
||||
private fb: FormBuilder,
|
||||
|
@ -40,8 +41,11 @@ export class RecoverPasswordComponent {
|
|||
validators: this.passwordMatchValidator,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Check if we're in reset mode
|
||||
ngOnInit(): void {
|
||||
// Check if we're in reset mode via URL parameters
|
||||
// This is still needed for direct access via URLs with token
|
||||
this.route.queryParamMap.subscribe((params) => {
|
||||
const token = params.get('token');
|
||||
if (token) {
|
||||
|
@ -111,7 +115,8 @@ export class RecoverPasswordComponent {
|
|||
'Dein Passwort wurde erfolgreich zurückgesetzt. Du kannst dich jetzt anmelden.'
|
||||
);
|
||||
setTimeout(() => {
|
||||
this.router.navigate([''], { queryParams: { login: true } });
|
||||
this.closeDialog.emit();
|
||||
this.switchToLogin.emit();
|
||||
}, 3000);
|
||||
},
|
||||
error: (err) => {
|
||||
|
@ -122,4 +127,8 @@ export class RecoverPasswordComponent {
|
|||
},
|
||||
});
|
||||
}
|
||||
|
||||
goBackToLogin(): void {
|
||||
this.switchToLogin.emit();
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue