-
Notifications
You must be signed in to change notification settings - Fork 14
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
Validate user account value #47
Validate user account value #47
Conversation
@garrett please see rhinstaller/anaconda#5305 (review) |
984388b
to
b002be4
Compare
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.
I've made a bunch of suggestions.
src/components/users/Accounts.jsx
Outdated
valid = null; | ||
} else if (userAccount.length > 32) { | ||
valid = false; | ||
setUserAccountInvalidHint(_("The user name is too long")); |
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.
Order of preference for the account name is:
- Account name (doesn't use "user"; this is good, as "user" is bad to show in interfaces)
- Username (the actual word, according to English dictionaries)
- User name (an uncommon variant, according to English dictionaries)
As both GNOME and KDE talk about "user" accounts and have a "name" field, I guess keeping with "User name" is probably OK enough for consistency, even if it's not ideal.
Therefore, this is fine.
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.
On the other hand, it would be good to mention what the cutoff is.
setUserAccountInvalidHint(_("The user name is too long")); | |
setUserAccountInvalidHint(_("User names must contain fewer than 33 characters")); |
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.
Updated
src/components/users/Accounts.jsx
Outdated
setUserAccountInvalidHint(_("The user name is too long")); | ||
} else if (reservedNames.includes(userAccount)) { | ||
valid = false; | ||
setUserAccountInvalidHint(_("Sorry, that user name is not available. Please try another.")); |
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.
Since this is blocked exclusively because it is reserved word, it might be nice to say that specifically here.
setUserAccountInvalidHint(_("Sorry, that user name is not available. Please try another.")); | |
setUserAccountInvalidHint(_("This is a reserved word; please try another user name")); |
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.
Updated
src/components/users/Accounts.jsx
Outdated
setUserAccountInvalidHint(_("Sorry, that user name is not available. Please try another.")); | ||
} else if (isUserAccountWithInvalidCharacters(userAccount)) { | ||
valid = false; | ||
setUserAccountInvalidHint(cockpit.format(_("The user name should usually only consist of lower case letters from a-z, digits and the following characters: $0"), "-_")); |
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.
A few improvements:
- Rewording
- "lowercase" is one word
- Oxford comma for an inline list
setUserAccountInvalidHint(cockpit.format(_("The user name should usually only consist of lower case letters from a-z, digits and the following characters: $0"), "-_")); | |
setUserAccountInvalidHint(cockpit.format(_("User names may only contain lowercase letters from a-z, digits, and the following characters: $0"), "-_")); |
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.
Updated
(My name has two Rs and two Ts.) |
Sorry for that, relying on auto-completion makes me ignorant, now I'll remember :) |
b002be4
to
577a227
Compare
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.
Thanks for the screenshots!
I'm looking at this all again, in context now, with a clearer head (less of a post-COVID headache today), and I have another round of suggestions. Apologies!
This time around, I'll show high fidelity mockups and explain it:
- Since we're talking about "user names", we should be consistent with the label.
- This is using PatternFly recommendations for errors in the forms, with the red helper text .
- I shortened the text to "User name must be shorter than 33 characters"
- Like the original mockups, the user name field is shorter, to show the limit visually. (It should roughly fit 33 wide characters, like 33 "w"s side by side, plus a little padding for the error icon.)
- We don't need to say "please change" as that's implied
- I changed the text to be a little clearer
- I've added a (?) icon for a popover to explain it
- The popover shows the reserved words
- This icon and popover is a "nice to have" and should be a follow-up... do not block this PR for it 😉
- I changed the text to be shorter for the description and made it more consistent with the details (with the word first, then symbols after)
Again: Apologies for another review with different changes after you already addressed what I said yesterday. Thanks in advance!
I've also attached the changes as suggestions here, so I hope that makes it easier to apply. I did not see where the "User account" label is in this PR (so I could change it to "User name", to make it more consistent with the rest of the writing as well as with GNOME, KDE, and probably other desktops.)
src/components/users/Accounts.jsx
Outdated
valid = null; | ||
} else if (userAccount.length > 32) { | ||
valid = false; | ||
setUserAccountInvalidHint(_("User names must contain fewer than 33 characters")); |
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.
setUserAccountInvalidHint(_("User names must contain fewer than 33 characters")); | |
setUserAccountInvalidHint(_("User name must be shorter than 33 characters")); |
src/components/users/Accounts.jsx
Outdated
setUserAccountInvalidHint(_("User names must contain fewer than 33 characters")); | ||
} else if (reservedNames.includes(userAccount)) { | ||
valid = false; | ||
setUserAccountInvalidHint(_("This is a reserved word; please try another user name")); |
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.
setUserAccountInvalidHint(_("This is a reserved word; please try another user name")); | |
setUserAccountInvalidHint(_("User name must not be a reserved word")); |
src/components/users/Accounts.jsx
Outdated
setUserAccountInvalidHint(_("This is a reserved word; please try another user name")); | ||
} else if (isUserAccountWithInvalidCharacters(userAccount)) { | ||
valid = false; | ||
setUserAccountInvalidHint(cockpit.format(_("User names may only contain lowercase letters from a-z, digits, and the following characters: $0"), "-._")); |
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.
setUserAccountInvalidHint(cockpit.format(_("User names may only contain lowercase letters from a-z, digits, and the following characters: $0"), "-._")); | |
setUserAccountInvalidHint(cockpit.format(_("User name may only contain: letters from a-z, digits 0-9, dash -, period ., and underscore _"))); |
1fb49ea
to
da5daf8
Compare
Modified. 33 "w"s seems maybe too wide to me (too close to the width of the other entries) but I am ok with it:
Updated
I'd leave it as eventual follow-up.
Updated. |
Thanks for the changes!
Yeah, that does seem wide. I guess on a larger resolution screen, there might be more of a difference?
Yeah, agreed on both points. It's pretty unlikely someone will hit multiples of the reserved words. Having it be a follow-up is totally fine. Forgetting to follow-up is probably OK too, as it's pretty unlikely.
Should we have an error for numbers only then? "User names must contain at least one letter from a-z." Although I guess you could have a username of |
@@ -55,6 +58,33 @@ export const accountsToDbusUsers = (accounts) => { | |||
}]; | |||
}; | |||
|
|||
const reservedNames = [ |
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.
This code now is duplicated pyanaconda/core/users.py
I will create an issue to expose it via an API and remove the duplication.
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.
I don't think so, actually the width of other entries is already limited by limiting the form width: https://github.com/rvykydal/anaconda-webui/blob/da5daf8533c5b030f8a78d36a0c1c8ec099aead7/src/components/users/Accounts.scss#L3.
If anything, I'd say something like "numbers-only user name is not allowed" because for example these are valid: |
So that it indicates that the length of the name is limited to the user.
For better consistency with system tools.
da5daf8
to
8bde528
Compare
The PR was originally open on anaconda repository and has some history and discussion there: rhinstaller/anaconda#5305