-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: using initial username as id and preventing later edits #1503
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,23 @@ export class User extends Entity { | |
label: $localize`:Label of username:Username`, | ||
validators: { required: true }, | ||
}) | ||
name: string; | ||
set name(value: string) { | ||
if (this._name) { | ||
// Throwing error if trying to change existing username | ||
const label = User.schema.get("name").label; | ||
throw new Error( | ||
$localize`:Error message when trying to change the username|e.g. username cannot be changed after initialization:${label} cannot be changed after initialization` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. best practices would suggest to not mix logic (the Entity model here) with UI (translating an error message), I think. The clean but more complex approach would be to define error codes or classes and only put human-readable and translated error messages when displaying it to the user. But I have my doubts that complexity is a worthy trade off here. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely a good thought. At the moment we are missing a general display error approach where we could translate these errors to a user friendly name. |
||
); | ||
} | ||
this.entityId = value; | ||
this._name = value; | ||
} | ||
|
||
get name(): string { | ||
return this._name; | ||
} | ||
|
||
private _name: string; | ||
|
||
/** | ||
* settings for the mat-paginator for tables. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's maybe change the property to
username
(or will this break dozens of things?). For some clients we introduced additional firstname and lastname properties to be used in the UI. "username" would make the purpose of this one more explicitThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment it would break a dozens of things (all the current user entities) So lets get this out and if we ever want to migrate this, we can do this independently.