diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2020-02-26 14:55:53 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2020-02-26 17:19:33 +0100 |
| commit | fd22e8bacc2169f5a441470e4b3117d536bc95cf (patch) | |
| tree | b241e14e49253d01a585c30d3f0fc78cc4035d5d | |
| parent | 6aa693b2e29b4691500890beb538f8bbcf66f5a6 (diff) | |
| download | mullvadvpn-fd22e8bacc2169f5a441470e4b3117d536bc95cf.tar.xz mullvadvpn-fd22e8bacc2169f5a441470e4b3117d536bc95cf.zip | |
Add methods to manipulate the TOS agreement flag
| -rw-r--r-- | ios/MullvadVPN/Account.swift | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ios/MullvadVPN/Account.swift b/ios/MullvadVPN/Account.swift index bd82097477..7ee61f5a76 100644 --- a/ios/MullvadVPN/Account.swift +++ b/ios/MullvadVPN/Account.swift @@ -69,6 +69,7 @@ extension AccountError: LocalizedError { /// A enum holding the `UserDefaults` string keys private enum UserDefaultsKeys: String { + case isAgreedToTermsOfService = "isAgreedToTermsOfService" case accountToken = "accountToken" case accountExpiry = "accountExpiry" } @@ -79,6 +80,11 @@ class Account { static let shared = Account() private let apiClient = MullvadAPI() + /// Returns true if user agreed to terms of service, otherwise false + var isAgreedToTermsOfService: Bool { + return UserDefaults.standard.bool(forKey: UserDefaultsKeys.isAgreedToTermsOfService.rawValue) + } + /// Returns the currently used account token var token: String? { return UserDefaults.standard.string(forKey: UserDefaultsKeys.accountToken.rawValue) @@ -93,6 +99,11 @@ class Account { return token != nil } + /// Save the boolean flag in preferences indicating that the user agreed to terms of service. + func agreeToTermsOfService() { + UserDefaults.standard.set(true, forKey: UserDefaultsKeys.isAgreedToTermsOfService.rawValue) + } + /// Perform the login and save the account token along with expiry (if available) to the /// application preferences. func login(with accountToken: String) -> AnyPublisher<(), AccountError> { |
