mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-17 04:09:21 +00:00
Re-enabled password request before saving a database that has no password and key
Stripped logging code Fixed issue with save panel not being updated correctly when panel is just reshown
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
@interface MPDocumentWindowController () {
|
||||
@private
|
||||
id _firstResponder;
|
||||
BOOL _saveAfterPasswordChange;
|
||||
}
|
||||
|
||||
@property (strong) IBOutlet NSSplitView *splitView;
|
||||
@@ -51,6 +52,7 @@
|
||||
self = [super initWithWindowNibName:@"DocumentWindow" owner:self];
|
||||
if( self ) {
|
||||
_firstResponder = nil;
|
||||
_saveAfterPasswordChange = NO;
|
||||
_toolbarDelegate = [[MPToolbarDelegate alloc] init];
|
||||
_outlineViewController = [[MPOutlineViewController alloc] init];
|
||||
_entryViewController = [[MPEntryViewController alloc] init];
|
||||
@@ -153,6 +155,7 @@
|
||||
|
||||
#pragma mark Actions
|
||||
- (void)saveDocument:(id)sender {
|
||||
_saveAfterPasswordChange = NO;
|
||||
MPDocument *document = [self document];
|
||||
NSString *fileType = [document fileType];
|
||||
/* we did open as legacy */
|
||||
@@ -166,15 +169,20 @@
|
||||
[alert addButtonWithTitle:NSLocalizedString(@"CANCEL", "Cancel")];
|
||||
|
||||
[[alert buttons][1] setKeyEquivalent:[NSString stringWithFormat:@"%c", 0x1b]];
|
||||
|
||||
[alert beginSheetModalForWindow:[self window] modalDelegate:nil didEndSelector:NULL contextInfo:NULL];
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!document.hasPasswordOrKey) {
|
||||
NSLog(@"No Password and/or kefile set");// warning if no password ist set!
|
||||
else if(!document.hasPasswordOrKey) {
|
||||
_saveAfterPasswordChange = YES;
|
||||
[self editPassword:sender];
|
||||
return;
|
||||
}
|
||||
[[self document] saveDocument:sender];
|
||||
else {
|
||||
/* All set and good ready to save */
|
||||
[[self document] saveDocument:sender];
|
||||
}
|
||||
|
||||
}
|
||||
- (void)exportDatabase:(id)sender {
|
||||
NSSavePanel *savePanel = [NSSavePanel savePanel];
|
||||
@@ -274,7 +282,10 @@
|
||||
- (void)editPassword:(id)sender {
|
||||
if(!self.passwordEditWindowController) {
|
||||
self.passwordEditWindowController = [[MPPasswordEditWindowController alloc] initWithDocument:[self document]];
|
||||
self.passwordEditWindowController.delegate = self;
|
||||
}
|
||||
/* Disallow empty password if we want to save afterwards, otherwise the dialog keeps poping up */
|
||||
self.passwordEditWindowController.allowsEmptyPasswordOrKey = !_saveAfterPasswordChange;
|
||||
[NSApp beginSheet:[self.passwordEditWindowController window] modalForWindow:[self window] modalDelegate:nil didEndSelector:NULL contextInfo:NULL];
|
||||
}
|
||||
|
||||
@@ -392,6 +403,14 @@
|
||||
[_outlineViewController showOutline];
|
||||
}
|
||||
|
||||
#pragma mark MPPasswordEditWindowDelegate
|
||||
- (void)didFinishPasswordEditing:(BOOL)changedPasswordOrKey {
|
||||
if(changedPasswordOrKey && _saveAfterPasswordChange) {
|
||||
[self saveDocument:nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Helper
|
||||
- (void)_showDatabaseSetting:(MPDatabaseSettingsTab)tab {
|
||||
if(!self.documentSettingsWindowController) {
|
||||
|
||||
Reference in New Issue
Block a user