-
Notifications
You must be signed in to change notification settings - Fork 114
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 password strength feedback for empty password #6008
Conversation
**Why**: To ensure they're included in the locale bundles generated by RailsI18nWebpackPlugin
**Why**: So that they don't create a run-on sentence, since each string does not terminate as a full sentence
**Why**: So that the feedback matches the initial state on a new page load, per the expectation of LG-5461
@@ -69,6 +70,7 @@ function getFeedback(z) { | |||
// i18n-tasks-use t('zxcvbn.feedback.this_is_a_top_10_common_password') | |||
// i18n-tasks-use t('zxcvbn.feedback.this_is_a_very_common_password') | |||
// i18n-tasks-use t('zxcvbn.feedback.this_is_similar_to_a_commonly_used_password') | |||
// i18n-tasks-use t('zxcvbn.feedback.use_a_few_words_avoid_common_phrases') | |||
// i18n-tasks-use t('zxcvbn.feedback.use_a_longer_keyboard_pattern_with_more_turns') | |||
return t(`zxcvbn.feedback.${snakeCase(str)}`); |
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 isn't the first time we've had some missing translations with zxcvbn (#5776 comes to mind) is there a better way we can list these, or maybe a safer fallback we can use than to print the slug?
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 isn't the first time we've had some missing translations with zxcvbn (#5776 comes to mind) is there a better way we can list these, or maybe a safer fallback we can use than to print the slug?
Yeah, these changes should have been included in #5776. As far as preventative measures, I mentioned at the time that it's a bit hard to test for. There was also a reference to formigarafa/zxcvbn-rb#4 where similar issues had been reported upstream. Since that time, there's been a comment of all strings we should cross-reference to our translations.
Aside from that, some ideas we could consider:
- Auto-include all
zxcvbn.feedback
keys into the locale string extraction - Don't print original key if there is no translation (at least avoid the non-human-readable text from being shown)
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 like both those, including all zxcvbn and also not passing through the key (maybe we add a default:
option like ruby i18n has, and we call back to something general like "please use a different password")
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.
Another idea is to use TypeScript to enforce coverage for all strings, but the DefinitelyTyped types appear to only list out the warnings, and not the suggestions.
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 double-checked the list in formigarafa/zxcvbn-rb#4 (comment) and made sure we have all strings listed there. I also added a spec in 6649e74 for the specific behavior being introduced here for an empty password. I was going to add a spec for the joining, though from looking at the source code, it doesn't appear there's a combination that could result in a multi-suggestion result being used, since we defer to a warning if it's present.
The ideas in #6008 (comment) are reasonable improvements, but moving forward I might suggest to propose an upstream improvement to the DefinitelyTyped type definitions to include all possible suggestions, then update our implementation to strongly type the feedback mappings, e.g.:
const FEEDBACK: Record<ZXCVBNFeedbackWarning & ZXCVBNFeedbackSuggestion, string> = {
"Straight rows of keys are easy to guess": '...',
// ...
};
changelog: Bug Fixes, Password Entry, Add missing messages for password strength feedback
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.
LGTM
Previously: #5776 (LG-5461)
This improves a few things around password strength feedback:
RailsI18nWebpackPlugin
(2902141)Steps to reproduce: