diff --git a/src/frontend/packages/core/src/features/user-profile/edit-profile-info/edit-profile-info.component.html b/src/frontend/packages/core/src/features/user-profile/edit-profile-info/edit-profile-info.component.html index f83ef80ba6..8377145582 100644 --- a/src/frontend/packages/core/src/features/user-profile/edit-profile-info/edit-profile-info.component.html +++ b/src/frontend/packages/core/src/features/user-profile/edit-profile-info/edit-profile-info.component.html @@ -19,13 +19,16 @@

Edit User Profile

-

Current password is required when changing email address

-

Current password is required when changing email address or password

- +

Current password is required when changing email address

+

Current password is required when changing email address or password

+

Change Password (Leave blank to keep current password)

+ + + diff --git a/src/frontend/packages/core/src/features/user-profile/edit-profile-info/edit-profile-info.component.ts b/src/frontend/packages/core/src/features/user-profile/edit-profile-info/edit-profile-info.component.ts index c05f60543f..d76fa89193 100644 --- a/src/frontend/packages/core/src/features/user-profile/edit-profile-info/edit-profile-info.component.ts +++ b/src/frontend/packages/core/src/features/user-profile/edit-profile-info/edit-profile-info.component.ts @@ -23,6 +23,8 @@ export class EditProfileInfoComponent implements OnInit, OnDestroy { editProfileForm: FormGroup; + needsPasswordForEmailChange: boolean; + constructor( private userProfileService: UserProfileService, private fb: FormBuilder, @@ -36,6 +38,8 @@ export class EditProfileInfoComponent implements OnInit, OnDestroy { newPassword: '', confirmPassword: '', }); + + this.needsPasswordForEmailChange = false; } private sub: Subscription; @@ -56,6 +60,9 @@ export class EditProfileInfoComponent implements OnInit, OnDestroy { ngOnInit() { this.userProfileService.fetchUserProfile(); this.userProfileService.userProfile$.pipe(first()).subscribe(profile => { + // UAA needs the user's password for email changes. Local user does not + // Both need it for password change + this.needsPasswordForEmailChange = (profile.origin === 'uaa'); this.profile = profile; this.emailAddress = this.userProfileService.getPrimaryEmailAddress(profile); this.editProfileForm.setValue({ @@ -76,7 +83,10 @@ export class EditProfileInfoComponent implements OnInit, OnDestroy { onChanges() { this.sub = this.editProfileForm.valueChanges.subscribe(values => { - const required = values.emailAddress !== this.emailAddress || values.newPassword.length; + // Old password is required if either email or new pw is specified (uaa) + // or only if new pw is specified (local account) + const required = this.needsPasswordForEmailChange ? + values.emailAddress !== this.emailAddress || values.newPassword.length : values.newPassword.length; this.passwordRequired = !!required; if (required !== this.lastRequired) { this.lastRequired = required; diff --git a/src/frontend/packages/core/src/features/user-profile/profile-info/profile-info.component.html b/src/frontend/packages/core/src/features/user-profile/profile-info/profile-info.component.html index b949cbccb2..92ae47a731 100644 --- a/src/frontend/packages/core/src/features/user-profile/profile-info/profile-info.component.html +++ b/src/frontend/packages/core/src/features/user-profile/profile-info/profile-info.component.html @@ -12,7 +12,7 @@

User Profile

text: '' }"> + name="{{ profile.name.givenName }} {{ profile.name.familyName }}" email="{{ primaryEmailAddress$ | async }}" username="{{ profile.userName }}">