mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 04:21:57 +03:00
Merge pull request #4012 from matrix-org/dbkr/just_one_zxcvbn_suggestion
Only display the first zxcvbn warning/suggestion
This commit is contained in:
commit
630507304a
1 changed files with 11 additions and 6 deletions
|
@ -453,14 +453,19 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
|
||||||
if (this.state.zxcvbnResult.score >= PASSWORD_MIN_SCORE) {
|
if (this.state.zxcvbnResult.score >= PASSWORD_MIN_SCORE) {
|
||||||
helpText = _t("Great! This passphrase looks strong enough.");
|
helpText = _t("Great! This passphrase looks strong enough.");
|
||||||
} else {
|
} else {
|
||||||
const suggestions = [];
|
// We take the warning from zxcvbn or failing that, the first
|
||||||
for (let i = 0; i < this.state.zxcvbnResult.feedback.suggestions.length; ++i) {
|
// suggestion. In practice The first is generally the most relevant
|
||||||
suggestions.push(<div key={i}>{this.state.zxcvbnResult.feedback.suggestions[i]}</div>);
|
// and it's probably better to present the user with one thing to
|
||||||
}
|
// improve about their password than a whole collection - it can
|
||||||
const suggestionBlock = <div>{suggestions.length > 0 ? suggestions : _t("Keep going...")}</div>;
|
// spit out a warning and multiple suggestions which starts getting
|
||||||
|
// very information-dense.
|
||||||
|
const suggestion = (
|
||||||
|
this.state.zxcvbnResult.feedback.warning ||
|
||||||
|
this.state.zxcvbnResult.feedback.suggestions[0]
|
||||||
|
);
|
||||||
|
const suggestionBlock = <div>{suggestion || _t("Keep going...")}</div>;
|
||||||
|
|
||||||
helpText = <div>
|
helpText = <div>
|
||||||
{this.state.zxcvbnResult.feedback.warning}
|
|
||||||
{suggestionBlock}
|
{suggestionBlock}
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue