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

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

- Check if the app needs to clean the account info
parent 7e530794
......@@ -14,7 +14,14 @@ private let log = SwiftyBeaver.self
extension AccountProvider {
func refreshAndLogoutUnauthorized(force: Bool = false) {
if !force {
let migrationDone = Client.preferences.authMigrationSuccess
var forceRefreshToken = force
if migrationDone != true {
forceRefreshToken = true
}
if !forceRefreshToken {
guard let accountInfo = Client.providers.accountProvider.currentUser?.info else {
return
}
......@@ -25,13 +32,19 @@ extension AccountProvider {
}
}
refreshAccountInfo(force: force, { (info, error) in
refreshAccountInfo(force: forceRefreshToken, { (info, error) in
guard let error = error as? ClientError else {
let preferences = Client.preferences.editable()
preferences.authMigrationSuccess = true
preferences.commit()
return
}
guard self.isLoggedIn else {
return
}
if (error == .unauthorized) {
log.error("Account: Failed to refresh account info, user is unauthorized. Logging out...")
self.logout(nil)
......
......@@ -44,6 +44,12 @@ class Bootstrapper {
AppPreferences.shared.migrate()
// Check if should clean the account after delete the app and install again
if Client.providers.accountProvider.shouldCleanAccount {
//If first install, we need to ensure we don't have data from previous sessions in the Secure Keychain
Client.providers.accountProvider.cleanDatabase()
}
// PIALibrary
guard let bundledRegionsURL = AppConstants.Regions.bundleURL else {
......
......@@ -53,7 +53,7 @@ end
def shared_main_pods
pod 'AlamofireImage'
#library_by_path('')
library_by_git('0378cf9')
library_by_git('ab9dea7')
#library_by_version('~> 1.1.3')
end
......
......@@ -104,10 +104,10 @@ DEPENDENCIES:
- HockeySDK
- iRate
- MBProgressHUD
- PIALibrary/Library (from `https://github.com/pia-foss/client-library-apple`, commit `0378cf9`)
- PIALibrary/Mock (from `https://github.com/pia-foss/client-library-apple`, commit `0378cf9`)
- PIALibrary/UI (from `https://github.com/pia-foss/client-library-apple`, commit `0378cf9`)
- PIALibrary/VPN (from `https://github.com/pia-foss/client-library-apple`, commit `0378cf9`)
- PIALibrary/Library (from `https://github.com/pia-foss/client-library-apple`, commit `ab9dea7`)
- PIALibrary/Mock (from `https://github.com/pia-foss/client-library-apple`, commit `ab9dea7`)
- PIALibrary/UI (from `https://github.com/pia-foss/client-library-apple`, commit `ab9dea7`)
- PIALibrary/VPN (from `https://github.com/pia-foss/client-library-apple`, commit `ab9dea7`)
- PIATunnel (from `https://github.com/pia-foss/tunnel-apple`, commit `269d6d1`)
- SideMenu (= 3.1.5)
- TPKeyboardAvoiding
......@@ -138,7 +138,7 @@ SPEC REPOS:
EXTERNAL SOURCES:
PIALibrary:
:commit: 0378cf9
:commit: ab9dea7
:git: https://github.com/pia-foss/client-library-apple
PIATunnel:
:commit: 269d6d1
......@@ -146,7 +146,7 @@ EXTERNAL SOURCES:
CHECKOUT OPTIONS:
PIALibrary:
:commit: 0378cf9
:commit: ab9dea7
:git: https://github.com/pia-foss/client-library-apple
PIATunnel:
:commit: 269d6d1
......@@ -177,6 +177,6 @@ SPEC CHECKSUMS:
SwiftyBeaver: ccfcdf85a04d429f1633f668650b0ce8020bda3a
TPKeyboardAvoiding: cb69d5ddbe90ce0170e4bc2db1e5e41d4a3ad9a4
PODFILE CHECKSUM: 75d5ffd1eb6f04284f63a2b00566e9ac787eea74
PODFILE CHECKSUM: 5ecaebc0e975f33a87b1a404057ff778abc5cc74
COCOAPODS: 1.5.3
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