reset password
This commit is contained in:
15
src/app/modules/user/password/password.component.html
Normal file
15
src/app/modules/user/password/password.component.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<app-card>
|
||||
<div [formGroup]="form" class="form">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>E-Mail Addresse</mat-label>
|
||||
<input (keyup.enter)="onResetPassword()" formControlName="user" matInput>
|
||||
</mat-form-field>
|
||||
|
||||
<app-button-row>
|
||||
<button (click)="onResetPassword()" mat-button>neues Passwort anfordern</button>
|
||||
<p *ngIf="errorMessage" class="error">{{errorMessage|authMessage}}</p>
|
||||
</app-button-row>
|
||||
|
||||
</div>
|
||||
|
||||
</app-card>
|
||||
8
src/app/modules/user/password/password.component.less
Normal file
8
src/app/modules/user/password/password.component.less
Normal file
@@ -0,0 +1,8 @@
|
||||
.form {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
p.error {
|
||||
margin: 8px 10px;
|
||||
color: darkred;
|
||||
}
|
||||
25
src/app/modules/user/password/password.component.spec.ts
Normal file
25
src/app/modules/user/password/password.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {PasswordComponent} from './password.component';
|
||||
|
||||
describe('PasswordComponent', () => {
|
||||
let component: PasswordComponent;
|
||||
let fixture: ComponentFixture<PasswordComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PasswordComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PasswordComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
36
src/app/modules/user/password/password.component.ts
Normal file
36
src/app/modules/user/password/password.component.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {FormControl, FormGroup, Validators} from '@angular/forms';
|
||||
import {Router} from '@angular/router';
|
||||
import {UserService} from '../../../services/user.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-password',
|
||||
templateUrl: './password.component.html',
|
||||
styleUrls: ['./password.component.less']
|
||||
})
|
||||
export class PasswordComponent implements OnInit {
|
||||
public form: FormGroup;
|
||||
public errorMessage: string;
|
||||
|
||||
constructor(public userService: UserService, private router: Router) {
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.form = new FormGroup({
|
||||
user: new FormControl(null, [Validators.required, Validators.email])
|
||||
});
|
||||
}
|
||||
|
||||
public async onResetPassword() {
|
||||
this.form.updateValueAndValidity();
|
||||
if (this.form.valid) {
|
||||
try {
|
||||
await this.userService.changePassword(this.form.value.user);
|
||||
await this.router.navigateByUrl('/user/password-send');
|
||||
} catch (ex) {
|
||||
this.errorMessage = ex.code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user