feat: add user change password component (#660)

Fixes: #657
This commit is contained in:
Benura Abeywardena
2020-05-16 13:01:27 +05:30
committed by GitHub
parent 0c2af151f3
commit eb56bdc0ad
8 changed files with 172 additions and 2 deletions
@@ -8,6 +8,7 @@ import { UsersService } from '../users.service';
/** Custom Components */
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
import { ChangePasswordDialogComponent } from 'app/shared/change-password-dialog/change-password-dialog.component';
/**
* View user component.
@@ -58,4 +59,25 @@ export class ViewUserComponent implements OnInit {
});
}
/**
* Change Password of the Users.
*/
changeUserPassword() {
const changeUserPasswordDialogRef = this.dialog.open(ChangePasswordDialogComponent, {
width: '400px',
height: '300px'
});
changeUserPasswordDialogRef.afterClosed().subscribe((response: any) => {
if (response.password && response.repeatPassword) {
const password = response.password;
const repeatPassword = response.repeatPassword;
const firstname = this.userData.firstname;
const data = {password: password, repeatPassword: repeatPassword, firstname: firstname};
this.usersService.changePassword(this.userData.id, data).subscribe(() => {
this.router.navigate(['/users']);
});
}
});
}
}