Skip to content

Commit 3176f82

Browse files
committed
Added check that new passcode is different
1 parent fdc70db commit 3176f82

File tree

16 files changed

+82
-28
lines changed

16 files changed

+82
-28
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
# 3.7.11
1+
# 3.8.3
2+
* Added a check that the new passcode is different than the existing one (Closed [#170](https://github.com/rolandleth/LTHPasscodeViewController/issues/170)).
3+
* Improved the handling of `isSimple`.
4+
5+
# 3.8.2
6+
* Fixed the usage of `self.viewLoaded` to `self.isViewLoaded` (Closed [#168](https://github.com/rolandleth/LTHPasscodeViewController/issues/168)).
7+
8+
# 3.8.1
9+
* Fixed title for lockscreen with navbar (Closed [#165](https://github.com/rolandleth/LTHPasscodeViewController/issues/165)).
10+
11+
# 3.8.0
212
* Replaced all instances of `keyWindow` with `LTHMainWindow` (macro that expands `[UIApplication sharedApplication].windows[0]` - explanation in [#164](https://github.com/rolandleth/LTHPasscodeViewController/issues/164).
313
* Fixed a bug where the UI would not be visible (Closed [#163](https://github.com/rolandleth/LTHPasscodeViewController/issues/163)).
414
* Made simple passcode configurable (Closed [#157](https://github.com/rolandleth/LTHPasscodeViewController/issues/157)).

Demo/LTHPasscodeViewController Demo.xcodeproj/project.pbxproj

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,21 @@
2121
/* End PBXBuildFile section */
2222

2323
/* Begin PBXFileReference section */
24+
2A2964741DDF46D400F44FFA /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
25+
2A2964761DDF46D600F44FFA /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/InfoPlist.strings; sourceTree = "<group>"; };
26+
2A2964771DDF46D700F44FFA /* ro */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ro; path = ro.lproj/InfoPlist.strings; sourceTree = "<group>"; };
27+
2A2964781DDF46D800F44FFA /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/InfoPlist.strings; sourceTree = "<group>"; };
28+
2A2964791DDF46D900F44FFA /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/InfoPlist.strings; sourceTree = "<group>"; };
29+
2A29647A1DDF46DA00F44FFA /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/InfoPlist.strings; sourceTree = "<group>"; };
30+
2A29647B1DDF46DB00F44FFA /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/InfoPlist.strings; sourceTree = "<group>"; };
31+
2A29647C1DDF46DC00F44FFA /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/InfoPlist.strings; sourceTree = "<group>"; };
32+
2A29647D1DDF46DD00F44FFA /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/InfoPlist.strings; sourceTree = "<group>"; };
33+
2A29647E1DDF470E00F44FFA /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
2434
2A882AC11DBD21FC007A5FE7 /* LTHPasscodeViewController Demo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "LTHPasscodeViewController Demo.entitlements"; sourceTree = "<group>"; };
2535
2AE8000617D9503000DBDE63 /* LTHPasscodeViewController Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "LTHPasscodeViewController Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2636
2AE8000917D9503000DBDE63 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
2737
2AE8000B17D9503000DBDE63 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
2838
2AE8000D17D9503000DBDE63 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
29-
2AE8001317D9503000DBDE63 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
3039
2AE8001517D9503000DBDE63 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
3140
2AE8001717D9503000DBDE63 /* LTHPasscodeViewController Demo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "LTHPasscodeViewController Demo-Prefix.pch"; sourceTree = "<group>"; };
3241
2AE8001817D9503000DBDE63 /* LTHAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LTHAppDelegate.h; sourceTree = "<group>"; };
@@ -42,7 +51,6 @@
4251
2AF19592182C09D5005CE38A /* LTHKeychainUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = LTHKeychainUtils.m; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
4352
2AF4E8391848F9FE00AB18EE /* LTHPasscodeViewController Demo-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "LTHPasscodeViewController Demo-Info.plist"; sourceTree = "<group>"; };
4453
A74908881BFBA75E00C6DA16 /* LTHPasscodeViewController.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = LTHPasscodeViewController.bundle; sourceTree = "<group>"; };
45-
A749088A1BFBAB3900C6DA16 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/InfoPlist.strings; sourceTree = "<group>"; };
4654
E5FE63591BA05DCF00427B5F /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/InfoPlist.strings; sourceTree = "<group>"; };
4755
/* End PBXFileReference section */
4856

@@ -236,10 +244,18 @@
236244
2AE8001217D9503000DBDE63 /* InfoPlist.strings */ = {
237245
isa = PBXVariantGroup;
238246
children = (
239-
2AE8001317D9503000DBDE63 /* en */,
240247
2AF06FCC1A19F89E00C6F836 /* pt-PT */,
241248
E5FE63591BA05DCF00427B5F /* it */,
242-
A749088A1BFBAB3900C6DA16 /* pt */,
249+
2A2964741DDF46D400F44FFA /* en */,
250+
2A2964761DDF46D600F44FFA /* es */,
251+
2A2964771DDF46D700F44FFA /* ro */,
252+
2A2964781DDF46D800F44FFA /* ja */,
253+
2A2964791DDF46D900F44FFA /* fr */,
254+
2A29647A1DDF46DA00F44FFA /* ru */,
255+
2A29647B1DDF46DB00F44FFA /* ko */,
256+
2A29647C1DDF46DC00F44FFA /* nl */,
257+
2A29647D1DDF46DD00F44FFA /* pt */,
258+
2A29647E1DDF470E00F44FFA /* de */,
243259
);
244260
name = InfoPlist.strings;
245261
sourceTree = "<group>";

LTHPasscodeViewController/LTHPasscodeViewController.m

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ @interface LTHPasscodeViewController () <UITextFieldDelegate>
7373
@property (nonatomic, assign) CGFloat modifierForBottomVerticalGap;
7474
@property (nonatomic, assign) CGFloat fontSizeModifier;
7575

76+
@property (nonatomic, assign) BOOL newPasscodeEqualsOldPasscode;
7677
@property (nonatomic, assign) BOOL passcodeAlreadyExists;
7778
@property (nonatomic, assign) BOOL usesKeychain;
7879
@property (nonatomic, assign) BOOL displayedAsModal;
@@ -252,9 +253,8 @@ - (BOOL)_didPasscodeTimerEnd {
252253
NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
253254
// startTime wasn't saved yet (first app use and it crashed, phone force
254255
// closed, etc) if it returns -1.
255-
if (now - [self _timerStartTime] >= [self _timerDuration] ||
256-
[self _timerStartTime] == -1) return YES;
257-
return NO;
256+
return now - [self _timerStartTime] >= [self _timerDuration] ||
257+
[self _timerStartTime] == -1;
258258
}
259259

260260

@@ -1214,14 +1214,16 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang
12141214

12151215
if (typedString.length > _digitsCount) return NO;
12161216
}
1217-
else _OKButton.hidden = [typedString length] == 0;
1217+
else {
1218+
_OKButton.hidden = [typedString length] == 0;
1219+
}
12181220

12191221
return YES;
12201222
}
12211223

12221224
#pragma mark - Validation
12231225
- (void)_validateComplexPasscode {
1224-
NSLog(@"isValid %@", [self _validatePasscode:_passcodeTextField.text] ? @"YES" : @"NO");
1226+
[self _validatePasscode:_passcodeTextField.text];
12251227
}
12261228

12271229

@@ -1243,16 +1245,17 @@ - (BOOL)_validatePasscode:(NSString *)typedString {
12431245
}
12441246
// User entered his Passcode correctly and we are at the confirming screen.
12451247
else if (_isUserConfirmingPasscode) {
1246-
// User entered the confirmation Passcode correctly
1247-
if ([typedString isEqualToString: _tempPasscode]) {
1248-
[self _dismissMe];
1249-
}
1250-
// User entered the confirmation Passcode incorrectly, start over.
1251-
else {
1248+
// User entered the confirmation Passcode incorrectly, or the passcode is the same as the old one, start over.
1249+
_newPasscodeEqualsOldPasscode = [typedString isEqualToString:savedPasscode];
1250+
if (![typedString isEqualToString:_tempPasscode] || _newPasscodeEqualsOldPasscode) {
12521251
[self performSelector:@selector(_reAskForNewPasscode)
12531252
withObject:nil
12541253
afterDelay:_slideAnimationDuration];
12551254
}
1255+
// User entered the confirmation Passcode correctly.
1256+
else {
1257+
[self _dismissMe];
1258+
}
12561259
}
12571260
// Changing Passcode and the entered Passcode is correct.
12581261
else if ([typedString isEqualToString:savedPasscode]){
@@ -1443,7 +1446,7 @@ - (void)_resetUI {
14431446
} else {
14441447
_enterPasscodeLabel.text = LTHPasscodeViewControllerStrings(self.enterPasscodeString);
14451448
//hidden for enabling PIN
1446-
_enterPasscodeInfoLabel.hidden = (_isUserEnablingPasscode && _displayAdditionalInfoDuringSettingPasscode) ? NO : YES;
1449+
_enterPasscodeInfoLabel.hidden = !(_isUserEnablingPasscode && _displayAdditionalInfoDuringSettingPasscode);
14471450
}
14481451
}
14491452

@@ -1468,10 +1471,14 @@ - (void)_resetUIForReEnteringNewPasscode {
14681471
NSString *savedPasscode = [LTHKeychainUtils getPasswordForUsername: _keychainPasscodeUsername
14691472
andServiceName: _keychainServiceName
14701473
error: nil];
1471-
_enterPasscodeLabel.text = savedPasscode.length == 0 ? LTHPasscodeViewControllerStrings(self.enterPasscodeString) : LTHPasscodeViewControllerStrings(self.enterNewPasscodeString);
1472-
1474+
_enterPasscodeLabel.text = savedPasscode.length == 0
1475+
? LTHPasscodeViewControllerStrings(self.enterPasscodeString)
1476+
: LTHPasscodeViewControllerStrings(self.enterNewPasscodeString);
14731477
_failedAttemptLabel.hidden = NO;
1474-
_failedAttemptLabel.text = LTHPasscodeViewControllerStrings(@"Passcodes did not match. Try again.");
1478+
_failedAttemptLabel.text = _newPasscodeEqualsOldPasscode
1479+
? LTHPasscodeViewControllerStrings(@"Cannot reuse the same passcode")
1480+
: LTHPasscodeViewControllerStrings(@"Passcodes did not match. Try again.");
1481+
_newPasscodeEqualsOldPasscode = NO;
14751482
_failedAttemptLabel.backgroundColor = [UIColor clearColor];
14761483
_failedAttemptLabel.layer.borderWidth = 0;
14771484
_failedAttemptLabel.layer.borderColor = [UIColor clearColor].CGColor;
@@ -1500,12 +1507,8 @@ - (void)setIsSimple:(BOOL)isSimple inViewController:(UIViewController *)viewCont
15001507
- (BOOL)isSimple {
15011508
// Is in process of changing, but not finished ->
15021509
// we need to display UI accordingly
1503-
if (_isUserSwitchingBetweenPasscodeModes &&
1504-
(_isUserBeingAskedForNewPasscode || _isUserConfirmingPasscode)) {
1505-
return !_isSimple;
1506-
}
1507-
1508-
return _isSimple;
1510+
return (_isUserSwitchingBetweenPasscodeModes &&
1511+
(_isUserBeingAskedForNewPasscode || _isUserConfirmingPasscode)) == !_isSimple;
15091512
}
15101513

15111514
#pragma mark - Notification Observers
@@ -1638,6 +1641,7 @@ - (void)_loadMiscDefaults {
16381641
_hidesBackButton = YES;
16391642
_hidesCancelButton = YES;
16401643
_passcodeAlreadyExists = YES;
1644+
_newPasscodeEqualsOldPasscode = NO;
16411645
#if !(TARGET_IPHONE_SIMULATOR)
16421646
_allowUnlockWithTouchID = [self _allowUnlockWithTouchID];
16431647
#else

Localizations/LTHPasscodeViewController.bundle/de.lproj/LTHPasscodeViewController.strings

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@
2525

2626
"%i Passcode Failed Attempts" = "%i fehlgeschlagene Eingabeversuche";
2727

28-
"Unlock using Touch ID" = "Entsperrren mit Touch ID";
28+
"Unlock using Touch ID" = "Entsperrren mit Touch ID";
29+
30+
"Cannot reuse the same passcode" = "Sie können nicht denselben Pincode benutzen";

Localizations/LTHPasscodeViewController.bundle/en.lproj/LTHPasscodeViewController.strings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@
2828
"%i Passcode Failed Attempts" = "%i Passcode Failed Attempts";
2929

3030
"Unlock using Touch ID" = "Unlock using Touch ID";
31+
32+
"Cannot reuse the same passcode" = "Cannot reuse the same passcode";

Localizations/LTHPasscodeViewController.bundle/ro.lproj/LTHPasscodeViewController.strings

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@
2323

2424
"1 Passcode Failed Attempt" = "1 încercare eșuată";
2525

26-
"%i Passcode Failed Attempts" = "%i încercări eșuate";
26+
"%i Passcode Failed Attempts" = "%i încercări eșuate";
27+
28+
"Cannot reuse the same passcode" = "Nu puteți refolosi aceeași parolă";

Demo/LTHPasscodeViewController Demo/pt.lproj/InfoPlist.strings renamed to demo/lthpasscodeviewcontroller demo/de.lproj/InfoPlist.strings

File renamed without changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* Localized versions of Info.plist keys */
2+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* Localized versions of Info.plist keys */
2+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* Localized versions of Info.plist keys */
2+

0 commit comments

Comments
 (0)