mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
CST-6153 changes for current password field introduce
This commit is contained in:
@@ -67,6 +67,10 @@ export class ProfilePageComponent implements OnInit {
|
||||
* The password filled in, in the security form
|
||||
*/
|
||||
private password: string;
|
||||
/**
|
||||
* The current-password filled in, in the security form
|
||||
*/
|
||||
private currentPassword: string;
|
||||
|
||||
/**
|
||||
* The authenticated user
|
||||
@@ -138,15 +142,15 @@ export class ProfilePageComponent implements OnInit {
|
||||
*/
|
||||
updateSecurity() {
|
||||
const passEntered = isNotEmpty(this.password);
|
||||
|
||||
if (this.invalidSecurity) {
|
||||
this.notificationsService.error(this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'error.general'));
|
||||
}
|
||||
if (!this.invalidSecurity && passEntered) {
|
||||
const operation = {op: 'add', path: '/password', value: this.password} as Operation;
|
||||
this.epersonService.patch(this.currentUser, [operation]).pipe(
|
||||
getFirstCompletedRemoteData()
|
||||
).subscribe((response: RemoteData<EPerson>) => {
|
||||
const operations = [
|
||||
{ op: 'add', path: '/password', value: this.password },
|
||||
{ op: 'add', path: '/challenge', value: this.currentPassword }
|
||||
] as Operation[];
|
||||
this.epersonService.patch(this.currentUser, operations).pipe(getFirstCompletedRemoteData()).subscribe((response: RemoteData<EPerson>) => {
|
||||
if (response.hasSucceeded) {
|
||||
this.notificationsService.success(
|
||||
this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'success.title'),
|
||||
@@ -170,6 +174,14 @@ export class ProfilePageComponent implements OnInit {
|
||||
this.password = $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current-password value based on the value emitted from the security form
|
||||
* @param $event
|
||||
*/
|
||||
setCurrentPasswordValue($event: string) {
|
||||
this.currentPassword = $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit of the security form that triggers the updateProfile method
|
||||
*/
|
||||
|
Reference in New Issue
Block a user