Merge pull request #124 from writeas/fix-false-positive-on-login

Present error alert if token is invalid and ensure user is logged out
This commit is contained in:
Angelo Stavrow 2020-11-10 15:13:23 -05:00 committed by GitHub
commit 29aacd589e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -325,6 +325,12 @@ private extension WriteFreelyModel {
DispatchQueue.main.async {
LocalStorageManager().saveContext()
}
} catch WFError.unauthorized {
DispatchQueue.main.async {
self.loginErrorMessage = "Something went wrong, please try logging in again."
self.isPresentingLoginErrorAlert = true
}
self.logout()
} catch {
print(error)
}
@ -376,6 +382,12 @@ private extension WriteFreelyModel {
} catch {
print(error)
}
} catch WFError.unauthorized {
DispatchQueue.main.async {
self.loginErrorMessage = "Something went wrong, please try logging in again."
self.isPresentingLoginErrorAlert = true
}
self.logout()
} catch {
print("Error: Failed to fetch cached posts")
}