Skip to content

Commit

Permalink
TouchID unlock is now optional
Browse files Browse the repository at this point in the history
Added a CheckBox to the PasswordInput view, so the user can see and
manipulate, whether the TouchID feature is enabled or disabled. The
choice is remembered in the standard user defaults.
  • Loading branch information
Julius Zint committed Feb 14, 2021
1 parent 5157ec8 commit 700dd43
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
20 changes: 17 additions & 3 deletions MacPass/Base.lproj/PasswordInputView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
<outlet property="messageInfoTextField" destination="268" id="ahE-sq-QzR"/>
<outlet property="passwordTextField" destination="338" id="495"/>
<outlet property="togglePasswordButton" destination="408" id="493"/>
<outlet property="touchIDEnabled" destination="Hs8-Tc-ezo" id="eqF-wX-rvg"/>
<outlet property="touchIdButton" destination="mQA-C0-JyU" id="fM3-PG-1OB"/>
<outlet property="touchIdEnabled" destination="Hs8-Tc-ezo" id="9Go-LQ-mSw"/>
<outlet property="unlockButton" destination="2" id="ZRr-Ui-ExP"/>
<outlet property="view" destination="1" id="143"/>
</connections>
Expand All @@ -41,15 +43,15 @@
</pathCell>
</pathControl>
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="262">
<rect key="frame" x="230" y="305" width="48" height="48"/>
<rect key="frame" x="230" y="312" width="48" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="273"/>
<constraint firstAttribute="width" constant="48" id="456"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="02_MessageBoxWarningTemplate" id="263"/>
</imageView>
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="268">
<rect key="frame" x="199" y="281" width="110" height="16"/>
<rect key="frame" x="199" y="288" width="110" height="16"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Wrong password!" id="269">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
Expand Down Expand Up @@ -156,12 +158,22 @@ DQ
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Hs8-Tc-ezo">
<rect key="frame" x="72" y="287" width="72" height="18"/>
<buttonCell key="cell" type="check" title="TouchID" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="h3C-Z4-x7N">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="touchIdEnabledChanged:" target="-2" id="3pR-xA-wbI"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="262" firstAttribute="top" relation="greaterThanOrEqual" secondItem="1" secondAttribute="top" constant="20" symbolic="YES" id="276"/>
<constraint firstAttribute="centerX" secondItem="262" secondAttribute="centerX" id="286"/>
<constraint firstAttribute="centerY" secondItem="338" secondAttribute="centerY" id="386"/>
<constraint firstItem="338" firstAttribute="top" secondItem="268" secondAttribute="bottom" constant="8" symbolic="YES" id="400"/>
<constraint firstItem="338" firstAttribute="top" secondItem="268" secondAttribute="bottom" constant="15" id="400"/>
<constraint firstItem="268" firstAttribute="top" secondItem="262" secondAttribute="bottom" constant="8" symbolic="YES" id="402"/>
<constraint firstItem="408" firstAttribute="top" secondItem="338" secondAttribute="top" id="411"/>
<constraint firstItem="268" firstAttribute="centerX" secondItem="338" secondAttribute="centerX" id="447"/>
Expand All @@ -180,8 +192,10 @@ DQ
<constraint firstItem="txI-yI-5nE" firstAttribute="trailing" secondItem="241" secondAttribute="trailing" id="AVL-HO-SMq"/>
<constraint firstItem="17" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="EOa-K4-v7J"/>
<constraint firstItem="338" firstAttribute="leading" secondItem="d8O-Ha-rrS" secondAttribute="trailing" constant="8" symbolic="YES" id="KYs-Ia-SVl"/>
<constraint firstItem="Hs8-Tc-ezo" firstAttribute="leading" secondItem="d8O-Ha-rrS" secondAttribute="leading" id="MO7-cs-9KQ"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="tck-n8-s0U" secondAttribute="bottom" constant="20" symbolic="YES" id="Sny-FR-cY1"/>
<constraint firstItem="tck-n8-s0U" firstAttribute="trailing" secondItem="486" secondAttribute="trailing" id="UtJ-18-p5u"/>
<constraint firstItem="Hs8-Tc-ezo" firstAttribute="firstBaseline" secondItem="268" secondAttribute="firstBaseline" id="e94-Kz-Ohn"/>
<constraint firstItem="d8O-Ha-rrS" firstAttribute="centerY" secondItem="338" secondAttribute="centerY" id="kgB-jV-OGy"/>
<constraint firstItem="txI-yI-5nE" firstAttribute="top" secondItem="241" secondAttribute="bottom" constant="8" symbolic="YES" id="lfg-eB-T2O"/>
<constraint firstItem="txI-yI-5nE" firstAttribute="leading" secondItem="241" secondAttribute="leading" id="nGY-6Q-Vwy"/>
Expand Down
12 changes: 11 additions & 1 deletion MacPass/MPPasswordInputController.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#import "MPSettingsHelper.h"
#import "MPPathControl.h"
#import "MPTouchBarButtonCreator.h"
#import "MPSettingsHelper.h"

#import "HNHUi/HNHUi.h"

Expand All @@ -47,6 +48,7 @@ @interface MPPasswordInputController ()
@property (weak) IBOutlet NSButton *unlockButton;
@property (weak) IBOutlet NSButton *cancelButton;
@property (weak) IBOutlet NSButton *touchIdButton;
@property (weak) IBOutlet NSButton *touchIdEnabled;

@property (copy) NSString *message;
@property (copy) NSString *cancelLabel;
Expand Down Expand Up @@ -88,6 +90,11 @@ - (void)viewDidLoad {
[self.enablePasswordCheckBox bind:NSValueBinding toObject:self withKeyPath:NSStringFromSelector(@selector(enablePassword)) options:nil];
[self.togglePasswordButton bind:NSEnabledBinding toObject:self withKeyPath:NSStringFromSelector(@selector(enablePassword)) options:nil];
[self.passwordTextField bind:NSEnabledBinding toObject:self withKeyPath:NSStringFromSelector(@selector(enablePassword)) options:nil];
self.touchIdEnabled.hidden = true;
if (@available(macOS 10.13.4, *)) {
self.touchIdEnabled.hidden = false;
self.touchIdEnabled.state = [NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyEntryTouchIdEnabled];
}
[self _reset];
}

Expand Down Expand Up @@ -142,7 +149,7 @@ - (IBAction)_submit:(id)sender {
BOOL cancel = (sender == self.cancelButton);
BOOL result = self.completionHandler(password, self.keyPathControl.URL, cancel, &error);
if(cancel || result) {
if(result && self.keyPathControl.URL == nil) {
if(result && self.keyPathControl.URL == nil && self.touchIdEnabled.state) {
[self _storePasswordForTouchIDUnlock:password forDatabase:self.absoluteURLString];
}
return;
Expand Down Expand Up @@ -307,6 +314,9 @@ - (IBAction)resetKeyFile:(id)sender {
self.keyPathControl.URL = nil;
}
}
- (IBAction)touchIdEnabledChanged:(id)sender {
[NSUserDefaults.standardUserDefaults setBool:self.touchIdEnabled.state forKey:kMPSettingsKeyEntryTouchIdEnabled];
}

- (void)_reset {
self.showPassword = NO;
Expand Down
3 changes: 3 additions & 0 deletions MacPass/MPSettingsHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

#import <Cocoa/Cocoa.h>

/* TouchID */
APPKIT_EXTERN NSString *const kMPSettingsKeyEntryTouchIdEnabled;

/* Clipboard */
APPKIT_EXTERN NSString *const kMPSettingsKeyPasteboardClearTimeout;
APPKIT_EXTERN NSString *const kMPSettingsKeyClearPasteboardOnQuit;
Expand Down
2 changes: 2 additions & 0 deletions MacPass/MPSettingsHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
NSString *const kMPSettingsKeyAutotypeMatchTags = @"AutotypeMatchTags";
NSString *const kMPSettingsKeyGloablAutotypeAlwaysShowCandidateSelection = @"GloablAutotypeAlwaysShowCandidateSelection";

NSString *const kMPSettingsKeyEntryTouchIdEnabled = @"EnableSubsequentUnlocksWithTouchID";

NSString *const kMPSettingsKeyEntrySearchFilterContext = @"EntrySearchFilterContext";

NSString *const kMPSettingsKeyEnableQuicklookPreview = @"EnableQuicklookPreview";
Expand Down

0 comments on commit 700dd43

Please sign in to comment.