Files
ng-blog/web/src/app/components/change-password/change-password.component.ts
u80864958 30dac9f12f
All checks were successful
Release / publish (push) Successful in 4m9s
change password
2025-05-13 14:06:11 +02:00

40 lines
908 B
TypeScript

import { Component, EventEmitter, inject, Output, output } from '@angular/core';
import {
FormControl,
FormGroup,
ReactiveFormsModule,
Validators,
} from '@angular/forms';
import { AuthService } from '../../shared/services/auth.service';
@Component({
selector: 'app-change-password',
imports: [ReactiveFormsModule],
templateUrl: './change-password.component.html',
})
export class ChangePasswordComponent {
@Output() done = new EventEmitter();
private auth = inject(AuthService);
form = new FormGroup({
password: new FormControl('', [
Validators.required,
Validators.minLength(6),
]),
});
submit() {
if (this.form.invalid) {
this.form.markAllAsTouched();
return;
}
this.auth
.changePassword(this.form.controls.password.value!)
.then((success) => {
if (success) {
this.done.emit();
}
});
}
}