Commit 9bbaa10a authored by Jose Blaya's avatar Jose Blaya
Browse files

Flag to indicate if the app has migrated the auth token successfully

parent 0378cf9f
......@@ -48,6 +48,8 @@ protocol PlainStore: class {
var trustCellularData: Bool? { get set }
var authMigrationSuccess: Bool? { get set }
var mace: Bool? { get set }
// MARK: Lifecycle
......
......@@ -22,6 +22,8 @@ private protocol PreferencesStore: class {
var trustCellularData: Bool { get set }
var authMigrationSuccess: Bool { get set }
var shouldConnectForAllNetworks: Bool { get set }
var vpnType: String { get set }
......@@ -50,6 +52,7 @@ private extension PreferencesStore {
mace = source.mace
useWiFiProtection = source.useWiFiProtection
trustCellularData = source.trustCellularData
authMigrationSuccess = source.authMigrationSuccess
shouldConnectForAllNetworks = source.shouldConnectForAllNetworks
vpnType = source.vpnType
vpnDisconnectsOnSleep = source.vpnDisconnectsOnSleep
......@@ -130,6 +133,16 @@ extension Client {
accessedDatabase.plain.trustCellularData = newValue
}
}
/// Flag to indicate if we have retrieve the correct auth token
public fileprivate(set) var authMigrationSuccess: Bool {
get {
return accessedDatabase.plain.authMigrationSuccess ?? defaults.authMigrationSuccess
}
set {
accessedDatabase.plain.authMigrationSuccess = newValue
}
}
/// The option for connect the vpn when selecting connect when changing to cellular data from Settings.
public fileprivate(set) var shouldConnectForAllNetworks: Bool {
......@@ -252,6 +265,7 @@ extension Client.Preferences {
mace = false
useWiFiProtection = false
trustCellularData = true
authMigrationSuccess = false
shouldConnectForAllNetworks = false
vpnType = IPSecProfile.vpnType
vpnDisconnectsOnSleep = false
......@@ -298,6 +312,9 @@ extension Client.Preferences {
/// :nodoc:
public var trustCellularData: Bool
/// :nodoc:
public var authMigrationSuccess: Bool
/// :nodoc:
public var shouldConnectForAllNetworks: Bool
......
......@@ -42,6 +42,8 @@ class UserDefaultsStore: PlainStore, ConfigurationAccess {
static let trustCellularData = "TrustCellularData"
static let authMigrationSuccess = "AuthMigrationSuccess"
static let shouldConnectForAllNetworks = "ShouldConnectForAllNetworks"
static let cachedNetworks = "CachedNetworks"
......@@ -240,6 +242,18 @@ class UserDefaultsStore: PlainStore, ConfigurationAccess {
}
}
var authMigrationSuccess: Bool? {
get {
guard let value = backend.object(forKey: Entries.authMigrationSuccess) as? Bool else {
return nil
}
return value
}
set {
backend.set(newValue, forKey: Entries.authMigrationSuccess)
}
}
var shouldConnectForAllNetworks: Bool? {
get {
guard let value = backend.object(forKey: Entries.shouldConnectForAllNetworks) as? Bool else {
......@@ -276,6 +290,7 @@ class UserDefaultsStore: PlainStore, ConfigurationAccess {
backend.removeObject(forKey: Entries.shouldConnectForAllNetworks)
backend.removeObject(forKey: Entries.useWiFiProtection)
backend.removeObject(forKey: Entries.trustCellularData)
backend.removeObject(forKey: Entries.authMigrationSuccess)
backend.synchronize()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment