CST-6153 changes for current password field introduce

This commit is contained in:
nikunj59
2022-06-24 19:26:30 +05:30
parent f589b2f8de
commit 9e2a682a51
6 changed files with 56 additions and 12 deletions

View File

@@ -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
*/