rdt-client/client/src/app/profile/profile.component.ts
2022-10-18 10:53:00 -06:00

36 lines
813 B
TypeScript

import { Component } from '@angular/core';
import { AuthService } from '../auth.service';
@Component({
selector: 'app-profile',
templateUrl: './profile.component.html',
styleUrls: ['./profile.component.scss'],
})
export class ProfileComponent {
constructor(private authService: AuthService) {}
public username: string;
public password: string;
public saving = false;
public success: boolean;
public error: string;
public save(): void {
this.success = false;
this.error = null;
this.saving = true;
this.authService.update(this.username, this.password).subscribe(
() => {
this.success = true;
this.saving = false;
},
(err) => {
this.error = err.error;
this.success = false;
this.saving = false;
}
);
}
}