Skip to content
Permalink
Browse files

fix: fix UNKNOWN errors in passphrase strength

  • Loading branch information...
satazor committed May 4, 2019
1 parent 5bdf7be commit d240b45e6d813e99c8fb745cfa01a2b6c8b13ef1
Showing with 8 additions and 5 deletions.
  1. +8 −5 src/locker/locks/util/passphrase-strength.js
@@ -28,7 +28,7 @@ const feedbackMessages = [
code: 'USE_LONGER_KEYBOARD_PATTERNS',
},
{
regExp: /Repeats like "aaa" are easy to guess'/i,
regExp: /Repeats like "aaa" are easy to guess/i,
code: 'REPEATED_CHARS_ARE_EASY',
},
{
@@ -146,18 +146,21 @@ const checkPassphraseStrength = (passphrase) => {
{ value: 25, norm: 1 },
]);

const suggestions = feedback.suggestions.map(parseMessage);
const warning = feedback.warning ? parseMessage(feedback.warning) : null;

// If the score is less than 50% and there's no warning nor suggestions, make sure we have one
if (score < 0.5 && !feedback.warning && !feedback.suggestions.length) {
feedback.suggestions.push({
if (score < 0.5 && !warning && !suggestions.length) {
suggestions.push({
code: 'UNCOMMON_WORDS_ARE_BETTER',
message: 'Add another word or two, uncommon words are better',
});
}

return {
score,
warning: feedback.warning ? parseMessage(feedback.warning) : null,
suggestions: feedback.suggestions.map(parseMessage),
warning,
suggestions,
};
};

0 comments on commit d240b45

Please sign in to comment.
You can’t perform that action at this time.