update tslint -> eslint
This commit is contained in:
@@ -2,14 +2,18 @@
|
||||
<div [formGroup]="form" class="form">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>E-Mail Addresse</mat-label>
|
||||
<input (keyup.enter)="onResetPassword()" formControlName="user" matInput>
|
||||
<input
|
||||
(keyup.enter)="onResetPassword()"
|
||||
formControlName="user"
|
||||
matInput
|
||||
/>
|
||||
</mat-form-field>
|
||||
|
||||
<app-button-row>
|
||||
<app-button (click)="onResetPassword()" [icon]="faNewPassword">neues Passwort anfordern</app-button>
|
||||
<p *ngIf="errorMessage" class="error">{{errorMessage|authMessage}}</p>
|
||||
<app-button (click)="onResetPassword()" [icon]="faNewPassword"
|
||||
>neues Passwort anfordern
|
||||
</app-button>
|
||||
<p *ngIf="errorMessage" class="error">{{ errorMessage | authMessage }}</p>
|
||||
</app-button-row>
|
||||
|
||||
</div>
|
||||
|
||||
</app-card>
|
||||
|
||||
@@ -6,12 +6,13 @@ describe('PasswordComponent', () => {
|
||||
let component: PasswordComponent;
|
||||
let fixture: ComponentFixture<PasswordComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PasswordComponent]
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
void TestBed.configureTestingModule({
|
||||
declarations: [PasswordComponent],
|
||||
}).compileComponents();
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PasswordComponent);
|
||||
@@ -20,6 +21,6 @@ describe('PasswordComponent', () => {
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
void expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {FormControl, FormGroup, Validators} from '@angular/forms';
|
||||
import {AbstractControl, FormControl, FormGroup, Validators} from '@angular/forms';
|
||||
import {Router} from '@angular/router';
|
||||
import {UserService} from '../../../services/user/user.service';
|
||||
import {faWindowRestore} from '@fortawesome/free-solid-svg-icons/faWindowRestore';
|
||||
@@ -7,32 +7,33 @@ import {faWindowRestore} from '@fortawesome/free-solid-svg-icons/faWindowRestore
|
||||
@Component({
|
||||
selector: 'app-password',
|
||||
templateUrl: './password.component.html',
|
||||
styleUrls: ['./password.component.less']
|
||||
styleUrls: ['./password.component.less'],
|
||||
})
|
||||
export class PasswordComponent implements OnInit {
|
||||
public form: FormGroup;
|
||||
public errorMessage: string;
|
||||
public faNewPassword = faWindowRestore;
|
||||
|
||||
constructor(public userService: UserService, private router: Router) {
|
||||
}
|
||||
public constructor(public userService: UserService, private router: Router) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
const required = (c: AbstractControl) => Validators.required(c);
|
||||
const email = Validators.email;
|
||||
this.form = new FormGroup({
|
||||
user: new FormControl(null, [Validators.required, Validators.email])
|
||||
user: new FormControl(null, [required, email]),
|
||||
});
|
||||
}
|
||||
|
||||
public async onResetPassword() {
|
||||
public async onResetPassword(): Promise<void> {
|
||||
this.form.updateValueAndValidity();
|
||||
if (this.form.valid) {
|
||||
try {
|
||||
await this.userService.changePassword(this.form.value.user);
|
||||
const value = this.form.value as {user: string};
|
||||
await this.userService.changePassword(value.user);
|
||||
await this.router.navigateByUrl('/user/password-send');
|
||||
} catch (ex) {
|
||||
this.errorMessage = ex.code;
|
||||
} catch ({code}) {
|
||||
this.errorMessage = code as string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user