177.1. Test reset password (#25)
This commit is contained in:
@ -14,16 +14,16 @@
|
||||
<nav class="navbar navbar-expand-md breadcrumb">
|
||||
<div class="collapse navbar-collapse" id="navbarCollapse">
|
||||
<div class="nav nav-pills">
|
||||
<a class="nav-item nav-link active ml-1" (click)="changeTitle('Users')" data-toggle="tab">
|
||||
<a class="nav-item nav-link active ml-1" (click)="changeTitle('Users')" data-bs-toggle="tab" href="#users">
|
||||
<i class="fa fa-users"></i>
|
||||
Users
|
||||
</a>
|
||||
<a class="nav-item nav-link ml-3" (click)="changeTitle('Settings')" data-toggle="tab">
|
||||
<a class="nav-item nav-link ml-3" (click)="changeTitle('Settings')" data-bs-toggle="tab" href="#reset-password">
|
||||
<i class="fa fa-cogs"></i>
|
||||
Settings
|
||||
</a>
|
||||
<a class="nav-item nav-link move-right mr-3" (click)="changeTitle('Profile')" data-toggle="tab">
|
||||
Welcome,
|
||||
<a class="nav-item nav-link move-right mr-3" (click)="changeTitle('Profile')" data-bs-toggle="tab" href="#profile">
|
||||
Welcome, You ugly animal
|
||||
<i class="fa fa-user"></i>
|
||||
</a>
|
||||
</div>
|
||||
@ -97,6 +97,27 @@
|
||||
<button [hidden]="true" type="button" id="openUserEdit" data-bs-toggle="modal" data-bs-target="#editUserModal">
|
||||
</button>
|
||||
|
||||
<!-- change password -->
|
||||
<div class="tab-pane fade" id="reset-password">
|
||||
<form #resetPasswordForm="ngForm" (ngSubmit)="onResetPassword(resetPasswordForm)">
|
||||
<fieldset>
|
||||
<legend>User Password Management</legend>
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Email address</label>
|
||||
<input type="email" name="reset-password-email" required ngModel class="form-control"
|
||||
placeholder="Enter email (example@email.com)">
|
||||
<small class="form-text text-muted">We'll never share your email with anyone else.</small>
|
||||
</div>
|
||||
<button type="submit" [disabled]="resetPasswordForm.invalid" class="btn btn-primary">
|
||||
<i *ngIf="refreshing" class="fas fa-spinner fa-spin"></i>
|
||||
<span *ngIf="refreshing">Loading...</span>
|
||||
<span *ngIf="!refreshing">Reset Password</span>
|
||||
</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- modal user info -->
|
||||
<div *ngIf="selectedUser" class="modal fade bd-example-modal-lg" id="viewUserModal" tabindex="-1" role="dialog"
|
||||
aria-labelledby=""
|
||||
|
||||
@ -76,7 +76,11 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private sendErrorNotification(message: string) {
|
||||
this.notificationService.notify(NotificationType.ERROR, message ? message : 'An error occurred. Please try again')
|
||||
this, this.sendNotification(NotificationType.ERROR, message);
|
||||
}
|
||||
|
||||
private sendNotification(type: NotificationType, message: string) {
|
||||
this.notificationService.notify(type, message ? message : 'An error occurred. Please try again')
|
||||
}
|
||||
|
||||
public onAddNewUser(userForm: NgForm): void {
|
||||
@ -172,14 +176,15 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
|
||||
public onResetPassword(emailForm: NgForm): void {
|
||||
this.refreshing = true;
|
||||
let email = emailForm.value[''];
|
||||
let email = emailForm.value['reset-password-email'];
|
||||
let subscription = this.userService.resetPassword(email)
|
||||
.subscribe(
|
||||
(response: CustomHttpResponse) => {
|
||||
this.notificationService.notify(NotificationType.SUCCESS, response.message);
|
||||
},
|
||||
(errorResponse: HttpErrorResponse) => {
|
||||
this.sendErrorNotification(errorResponse.error.message);
|
||||
this.sendNotification(NotificationType.WARNING, errorResponse.error.message);
|
||||
this.refreshing = false;
|
||||
},
|
||||
() => {
|
||||
this.refreshing = false;
|
||||
|
||||
Reference in New Issue
Block a user