mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 08:12:28 +00:00
Locking a db now requests a password/key if none is set
This commit is contained in:
@@ -383,14 +383,14 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
|
|||||||
[passwordInputController requestPasswordWithMessage:NSLocalizedString(@"EXTERN_CHANGE_OF_MASTERKEY", @"The master key was changed by an extrenal programm!")
|
[passwordInputController requestPasswordWithMessage:NSLocalizedString(@"EXTERN_CHANGE_OF_MASTERKEY", @"The master key was changed by an extrenal programm!")
|
||||||
cancelLabel:NSLocalizedString(@"ABORT_MERGE_KEEP_MINE", @"Button label to abort a merge on a file with changed master key!")
|
cancelLabel:NSLocalizedString(@"ABORT_MERGE_KEEP_MINE", @"Button label to abort a merge on a file with changed master key!")
|
||||||
completionHandler:^BOOL(NSString *password, NSURL *keyURL, BOOL didCancel, NSError *__autoreleasing *error) {
|
completionHandler:^BOOL(NSString *password, NSURL *keyURL, BOOL didCancel, NSError *__autoreleasing *error) {
|
||||||
[self.windowForSheet endSheet:sheet returnCode:(didCancel ? NSModalResponseCancel : NSModalResponseOK)];
|
[self.windowForSheet endSheet:sheet returnCode:(didCancel ? NSModalResponseCancel : NSModalResponseOK)];
|
||||||
if(!didCancel) {
|
if(!didCancel) {
|
||||||
KPKCompositeKey *compositeKey = [[KPKCompositeKey alloc] initWithPassword:password key:keyURL];
|
KPKCompositeKey *compositeKey = [[KPKCompositeKey alloc] initWithPassword:password key:keyURL];
|
||||||
[self mergeWithContentsFromURL:url key:compositeKey];
|
[self mergeWithContentsFromURL:url key:compositeKey];
|
||||||
}
|
}
|
||||||
// just return yes regardless since we will display the sheet again if needed!
|
// just return yes regardless since we will display the sheet again if needed!
|
||||||
return YES;
|
return YES;
|
||||||
}];
|
}];
|
||||||
sheet.contentViewController = passwordInputController;
|
sheet.contentViewController = passwordInputController;
|
||||||
[self.windowForSheet beginSheet:sheet completionHandler:^(NSModalResponse returnCode) { /* nothing to do, rest is done in other handler! */ }];
|
[self.windowForSheet beginSheet:sheet completionHandler:^(NSModalResponse returnCode) { /* nothing to do, rest is done in other handler! */ }];
|
||||||
}
|
}
|
||||||
@@ -640,8 +640,8 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
|
|||||||
[newEntry addToGroup:parent];
|
[newEntry addToGroup:parent];
|
||||||
[newEntry.undoManager setActionName:NSLocalizedString(@"NEW_ENTRY", "")];
|
[newEntry.undoManager setActionName:NSLocalizedString(@"NEW_ENTRY", "")];
|
||||||
[NSNotificationCenter.defaultCenter postNotificationName:MPDocumentDidAddEntryNotification
|
[NSNotificationCenter.defaultCenter postNotificationName:MPDocumentDidAddEntryNotification
|
||||||
object:self
|
object:self
|
||||||
userInfo:@{ MPDocumentEntryKey: newEntry }];
|
userInfo:@{ MPDocumentEntryKey: newEntry }];
|
||||||
return newEntry;
|
return newEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -856,10 +856,8 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
|
|||||||
break;
|
break;
|
||||||
case MPActionDatabaseSettings:
|
case MPActionDatabaseSettings:
|
||||||
case MPActionEditPassword:
|
case MPActionEditPassword:
|
||||||
valid &= !self.encrypted;
|
|
||||||
break;
|
|
||||||
case MPActionLock:
|
case MPActionLock:
|
||||||
valid &= self.compositeKey.hasPasswordOrKeyFile;
|
valid &= !self.encrypted;
|
||||||
break;
|
break;
|
||||||
case MPActionShowEntryHistory:
|
case MPActionShowEntryHistory:
|
||||||
valid &= (nil != targetEntry);
|
valid &= (nil != targetEntry);
|
||||||
|
|||||||
@@ -343,8 +343,13 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
|||||||
|
|
||||||
- (IBAction)lock:(id)sender {
|
- (IBAction)lock:(id)sender {
|
||||||
MPDocument *document = [self document];
|
MPDocument *document = [self document];
|
||||||
if(!document.compositeKey.hasPasswordOrKeyFile) {
|
if(!document.compositeKey) {
|
||||||
return; // Document needs a password/keyfile to be lockable
|
[self editPasswordWithCompetionHandler:^(NSInteger result) {
|
||||||
|
if(result == NSModalResponseOK) {
|
||||||
|
[self lock:sender];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if(document.encrypted) {
|
if(document.encrypted) {
|
||||||
return; // Document already locked
|
return; // Document already locked
|
||||||
|
|||||||
Reference in New Issue
Block a user