Skip to content

Commit

Permalink
Added further strength level: all criteria need to be matched
Browse files Browse the repository at this point in the history
This regards #35
  • Loading branch information
Martin Stolz committed Nov 27, 2013
1 parent 1acf68a commit 397bede
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef enum
US2PasswordStrengthMedium = 2,
US2PasswordStrengthStrong = 3,
US2PasswordStrengthVeryStrong = 4,
US2PasswordMatchesAll = 5,
} US2PasswordStrength;


Expand All @@ -58,7 +59,8 @@ typedef enum
US2PasswordStrengthWeak = 1,
US2PasswordStrengthMedium = 2,
US2PasswordStrengthStrong = 3,
US2PasswordStrengthVeryStrong = 4, // All criteria is matched
US2PasswordStrengthVeryStrong = 4,
US2PasswordMatchesAll = 5, // All criteria is matched
If the password strength matches or is above the required strength than the condition will pass.
*/
Expand Down Expand Up @@ -98,7 +100,8 @@ typedef enum
* US2PasswordStrengthWeak
* US2PasswordStrengthMedium (Default Value)
* US2PasswordStrengthStrong
* US2PasswordStrengthVeryStrong (All criteria is matched)
* US2PasswordStrengthVeryStrong
* US2PasswordMatchesAll (All criteria is matched)
*/
@property (nonatomic) US2PasswordStrength requiredStrength;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,23 @@ - (NSUInteger)US2__strengthOfPasswordString:(NSString *)string
NSUInteger specialCharacterMatchesCount = [self US2__numberOfSpecialCharactersInString:string];

// For each match of each type, move the strength value up one (higher = stronger)
if (numberMatchesCount > _minimalNumbers)
{
if (numberMatchesCount >= _minimalNumbers)
{
strength++;
}

if (lowercaseMatchesCount > _minimalLowerCase)
{
if (lowercaseMatchesCount >= _minimalLowerCase)
{
strength++;
}

if (uppercaseMatchesCount > _minimalUpperCase)
{
if (uppercaseMatchesCount >= _minimalUpperCase)
{
strength++;
}

if (specialCharacterMatchesCount > _minimalSymbols)
{
if (specialCharacterMatchesCount >= _minimalSymbols)
{
strength++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
* US2PasswordStrengthWeak
* US2PasswordStrengthMedium (Default Value)
* US2PasswordStrengthStrong
* US2PasswordStrengthVeryStrong (All criteria is matched)
* US2PasswordStrengthVeryStrong
* US2PasswordMatchesAll (All criteria is matched)
*/
@property (nonatomic) US2PasswordStrength requiredStrength;
Expand Down

0 comments on commit 397bede

Please sign in to comment.