Commit 76774971 authored by Jose Blaya's avatar Jose Blaya
Browse files

Check if the app needs to clean the account info

parent 9bbaa10a
......@@ -15,7 +15,10 @@ public protocol AccountProvider: class {
/// The in-app products required to purchase a `Plan`.
var planProducts: [Plan: InAppProduct]? { get }
#endif
/// Returns `true` if accountInfo is nil and loggedIn true.
var shouldCleanAccount: Bool { get }
/// Returns `true` if currently logged in, `false` otherwise.
var isLoggedIn: Bool { get }
......
......@@ -47,6 +47,14 @@ class DefaultAccountProvider: AccountProvider, ConfigurationAccess, DatabaseAcce
return (accessedDatabase.secure.password(for: username) != nil)
}
var shouldCleanAccount: Bool {
if self.accessedDatabase.plain.accountInfo == nil,
self.isLoggedIn {
return true
}
return false
}
var publicUsername: String? {
guard let username = accessedDatabase.secure.publicUsername() else {
return nil
......
......@@ -106,6 +106,11 @@ public class MockAccountProvider: AccountProvider, WebServicesConsumer {
}
#endif
/// :nodoc:
public var shouldCleanAccount: Bool {
return false
}
/// :nodoc:
public var isLoggedIn: Bool {
return delegate.isLoggedIn
......
......@@ -324,6 +324,8 @@ class EphemeralAccountProvider: AccountProvider, ProvidersAccess, InAppAccess {
return accessedProviders.accountProvider.planProducts
}
var shouldCleanAccount = false
var isLoggedIn = false
var token: String?
......
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