diff --git a/MyPass/ViewModels/UnlockViewModel.swift b/MyPass/ViewModels/UnlockViewModel.swift index 218e94c..0bce4a2 100644 --- a/MyPass/ViewModels/UnlockViewModel.swift +++ b/MyPass/ViewModels/UnlockViewModel.swift @@ -78,7 +78,8 @@ final class UnlockViewModel: ObservableObject { func openFile(url: URL) { do { try bookmarkService.save(url: url) - unlockWithPassword() + // Don't attempt to unlock yet -- picking a file only saves the bookmark. + // The view now shows the password field for the user to enter their password. } catch { errorMessage = error.localizedDescription } diff --git a/MyPassCore/Sources/MyPassCore/KDBX/KDBXError.swift b/MyPassCore/Sources/MyPassCore/KDBX/KDBXError.swift index b33214a..5d4c079 100644 --- a/MyPassCore/Sources/MyPassCore/KDBX/KDBXError.swift +++ b/MyPassCore/Sources/MyPassCore/KDBX/KDBXError.swift @@ -6,3 +6,18 @@ public enum KDBXError: Error, Equatable { case parseError(String) case writeError(String) } + +extension KDBXError: LocalizedError { + public var errorDescription: String? { + switch self { + case .invalidPassword: + return "Incorrect password." + case .fileNotFound: + return "The vault file could not be found." + case .parseError(let message): + return "Couldn't open the vault: \(message)" + case .writeError(let message): + return "Couldn't save the vault: \(message)" + } + } +}