Skip to content

Commit b0fb75e

Browse files
committed
improvements for password handling
- do not enforce password policy, only requires password to be existent (i.e. >0) - added possibility to skip password protection - automatically unlocks database if no password is set
1 parent 1128a04 commit b0fb75e

File tree

4 files changed

+41
-10
lines changed

4 files changed

+41
-10
lines changed

TextSecureiOS/ViewControllers/TSSetMasterPasswordViewController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
@property (nonatomic, strong) IBOutlet UITextField *pass;
1515

1616
@property (strong, nonatomic) IBOutlet UIButton *nextButton;
17+
@property (strong, nonatomic) IBOutlet UIButton *skipButton;
1718

1819
@property (nonatomic, retain) IBOutlet UILabel *instruction;
1920

TextSecureiOS/ViewControllers/TSSetMasterPasswordViewController.m

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ - (IBAction) nextWasTapped:(id)sender{
8484
}
8585
}
8686

87+
- (IBAction)skipWasTapped:(id)sender {
88+
// TODO: AlertView(?) to help the user make an informed decision
89+
self.pass.text = @"";
90+
[self setupDatabase];
91+
}
92+
93+
8794
- (void) setupDatabase {
8895
NSError *error = nil;
8996

@@ -140,6 +147,12 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang
140147

141148
// Update password strenght for the new password
142149
[self updatePasswordStrength:self forPassword:newPass];
150+
151+
if (newPass.length > 0) {
152+
self.nextButton.enabled = YES;
153+
} else {
154+
self.nextButton.enabled = NO;
155+
}
143156

144157
return YES;
145158
}
@@ -153,10 +166,6 @@ - (void)didReceiveMemoryWarning
153166
#pragma mark - Password strength
154167
- (void)updatePasswordStrength:(id)sender forPassword:(NSString*)password {
155168

156-
// disable next button, will be enabled when password strength is reasonable
157-
// TODO: define a password policy that should be enforced
158-
self.nextButton.enabled = NO;
159-
160169
if ([password length] == 0) {
161170
self.passwordStrengthMeterView.progress = 0.0f;
162171
self.passwordStrengthLabel.text = NSLocalizedString(@"Invalid Password", nil) ;
@@ -178,17 +187,14 @@ - (void)updatePasswordStrength:(id)sender forPassword:(NSString*)password {
178187
case NJOReasonablePasswordStrength:
179188
self.passwordStrengthMeterView.progress = 0.5f;
180189
self.passwordStrengthMeterView.tintColor = [UIColor TSYellowWarningColor];
181-
self.nextButton.enabled = YES;
182190
break;
183191
case NJOStrongPasswordStrength:
184192
self.passwordStrengthMeterView.progress = 0.75f;
185193
self.passwordStrengthMeterView.tintColor = [UIColor TSValidColor];
186-
self.nextButton.enabled = YES;
187194
break;
188195
case NJOVeryStrongPasswordStrength:
189196
self.passwordStrengthMeterView.progress = 1.0f;
190197
self.passwordStrengthMeterView.tintColor = [UIColor TSValidColor];
191-
self.nextButton.enabled = YES;
192198
break;
193199
}
194200

TextSecureiOS/ViewControllers/TextSecureViewController.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,15 @@ -(void)viewDidAppear:(BOOL)animated {
7070
self.navigationController.navigationBarHidden = NO;
7171

7272
if([TSKeyManager hasVerifiedPhoneNumber] && [TSMessagesDatabase databaseWasCreated] && [TSStorageMasterKey isStorageMasterKeyLocked]) {
73-
[self performSegueWithIdentifier:@"PasswordUnlockSegue" sender:self];
73+
74+
// check if user decided to skip password protection
75+
NSError *error = nil;
76+
[TSStorageMasterKey unlockStorageMasterKeyUsingPassword:@"" error:&error];
77+
BOOL stillLocked = [TSStorageMasterKey isStorageMasterKeyLocked];
78+
79+
if (stillLocked) {
80+
[self performSegueWithIdentifier:@"PasswordUnlockSegue" sender:self];
81+
}
7482

7583
} else if([TSKeyManager hasVerifiedPhoneNumber] == NO) {
7684
[self performSegueWithIdentifier:@"ObtainVerificationCode" sender:self];

TextSecureiOS/en.lproj/MainStoryboard.storyboard

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
8585
<prototypes>
8686
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="TSContactCell" editingAccessoryType="checkmark" id="PQB-5D-1De">
87-
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
87+
<rect key="frame" x="0.0" y="22" width="320" height="44"/>
8888
<autoresizingMask key="autoresizingMask"/>
8989
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="PQB-5D-1De" id="tS4-a2-ecF">
9090
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
@@ -156,6 +156,21 @@
156156
<action selector="nextWasTapped:" destination="UTA-HQ-Ilx" eventType="touchUpInside" id="8oy-0E-pEe"/>
157157
</connections>
158158
</button>
159+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tHO-bB-EPm">
160+
<rect key="frame" x="0.0" y="308" width="320" height="40"/>
161+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
162+
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
163+
<fontDescription key="fontDescription" name="HelveticaNeue-Thin" family="Helvetica Neue" pointSize="23"/>
164+
<state key="normal" title="Skip">
165+
<color key="titleColor" red="0.39607843139999999" green="0.73333333329999995" blue="0.90588235289999997" alpha="1" colorSpace="calibratedRGB"/>
166+
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
167+
</state>
168+
<connections>
169+
<action selector="doVerifyPhone:" destination="G9I-Gu-J6D" eventType="touchUpInside" id="PbF-zZ-Ega"/>
170+
<action selector="nextWasTapped:" destination="UTA-HQ-Ilx" eventType="touchUpInside" id="cBp-BG-SSm"/>
171+
<action selector="skipWasTapped:" destination="UTA-HQ-Ilx" eventType="touchUpInside" id="fFa-i0-xye"/>
172+
</connections>
173+
</button>
159174
<progressView opaque="NO" alpha="0.69999999999999996" contentMode="scaleToFill" verticalHuggingPriority="750" fixedFrame="YES" progressViewStyle="bar" translatesAutoresizingMaskIntoConstraints="NO" id="prV-ge-1gh">
160175
<rect key="frame" x="20" y="241" width="280" height="3"/>
161176
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
@@ -190,6 +205,7 @@
190205
<outlet property="pass" destination="loe-TW-3kA" id="mlr-Lc-FQa"/>
191206
<outlet property="passwordStrengthLabel" destination="h8W-KQ-S8f" id="5pz-PR-kGx"/>
192207
<outlet property="passwordStrengthMeterView" destination="prV-ge-1gh" id="eaS-In-3hD"/>
208+
<outlet property="skipButton" destination="tHO-bB-EPm" id="Zpd-AC-GgK"/>
193209
<segue destination="KRb-Ro-u27" kind="custom" identifier="BeginUsingApp" customClass="TSStartOverSegue" id="P7Y-NC-M85"/>
194210
</connections>
195211
</viewController>
@@ -663,7 +679,7 @@
663679
<simulatedScreenMetrics key="destination" type="retina4"/>
664680
</simulatedMetricsContainer>
665681
<inferredMetricsTieBreakers>
682+
<segue reference="P7Y-NC-M85"/>
666683
<segue reference="H42-Az-Klt"/>
667-
<segue reference="IPq-is-JQN"/>
668684
</inferredMetricsTieBreakers>
669685
</document>

0 commit comments

Comments
 (0)