From caa30e7ef4d331f923b6e3691d016abb9fbfaae3 Mon Sep 17 00:00:00 2001 From: Neil MacDougall Date: Wed, 18 Sep 2019 20:25:53 +0100 Subject: [PATCH 1/2] Add support for view and edit profile for local user --- .../edit-profile-info.component.html | 9 +- .../edit-profile-info.component.ts | 7 + .../profile-info/profile-info.component.html | 20 ++- .../profile-info/profile-info.component.ts | 2 + .../user-profile-banner.component.html | 7 +- .../user-profile-banner.component.ts | 10 +- .../store/src/effects/user-profile.effects.ts | 6 +- src/jetstream/auth.go | 4 + .../20190918092300_LocalUsersUpdates.go | 33 ++++ src/jetstream/plugins/userinfo/local_user.go | 152 ++++++++++++++++++ src/jetstream/plugins/userinfo/main.go | 145 ++++++++++++++++- src/jetstream/plugins/userinfo/types.go | 40 +++++ .../userinfo/{user_info.go => uaa_user.go} | 75 ++++++--- .../repository/interfaces/localuser.go | 2 + .../repository/localusers/psql_localusers.go | 22 ++- src/jetstream/setup_console.go | 10 +- 16 files changed, 493 insertions(+), 51 deletions(-) create mode 100644 src/jetstream/datastore/20190918092300_LocalUsersUpdates.go create mode 100644 src/jetstream/plugins/userinfo/local_user.go create mode 100644 src/jetstream/plugins/userinfo/types.go rename src/jetstream/plugins/userinfo/{user_info.go => uaa_user.go} (57%) 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..5414f1f0bb 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..4de71c0598 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({ 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 }}">