Present error alert if token is invalid and ensure user is logged out

This commit is contained in:
Angelo Stavrow 2020-11-10 11:21:28 -05:00
parent 81b4d38aea
commit 76089ef759
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

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")
}