diff options
Diffstat (limited to 'client/src/app/shared/users/user.service.ts')
-rw-r--r-- | client/src/app/shared/users/user.service.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts index 20883456f..70ff9a058 100644 --- a/client/src/app/shared/users/user.service.ts +++ b/client/src/app/shared/users/user.service.ts | |||
@@ -136,6 +136,22 @@ export class UserService { | |||
136 | .pipe(catchError(res => this.restExtractor.handleError(res))) | 136 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
137 | } | 137 | } |
138 | 138 | ||
139 | getNewUsername (oldDisplayName: string, newDisplayName: string, currentUsername: string) { | ||
140 | // Don't update display name, the user seems to have changed it | ||
141 | if (this.displayNameToUsername(oldDisplayName) !== currentUsername) return currentUsername | ||
142 | |||
143 | return this.displayNameToUsername(newDisplayName) | ||
144 | } | ||
145 | |||
146 | displayNameToUsername (displayName: string) { | ||
147 | if (!displayName) return '' | ||
148 | |||
149 | return displayName | ||
150 | .toLowerCase() | ||
151 | .replace(/\s/g, '_') | ||
152 | .replace(/[^a-z0-9_.]/g, '') | ||
153 | } | ||
154 | |||
139 | /* ###### Admin methods ###### */ | 155 | /* ###### Admin methods ###### */ |
140 | 156 | ||
141 | addUser (userCreate: UserCreate) { | 157 | addUser (userCreate: UserCreate) { |