Skip to content

Commit

Permalink
fix: fix UNKNOWN errors in passphrase strength
Browse files Browse the repository at this point in the history
  • Loading branch information
satazor committed May 4, 2019
1 parent 5bdf7be commit d240b45
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/locker/locks/util/passphrase-strength.js
Expand Up @@ -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',
},
{
Expand Down Expand Up @@ -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,
};
};

Expand Down

0 comments on commit d240b45

Please sign in to comment.