Auto logout on unrecoverable authentication error.

When an unrecoverable authentication error occurs, automatically log
the user out.  This seems better than leaving the user wondering why
the UI is unresponsive or why each track they try to play fails with a
quickly disappearing toast.

Unrecoverable authentication errors typically mean the server has
timed out the session out or the session token has been deleted on the
server.  Tokens expire after 14 days without use.

Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale-android/-/merge_requests/342>
This commit is contained in:
Hugh Daschbach 2023-12-15 17:55:07 -08:00 committed by Marge
parent 467556d75c
commit 6f24535b79
2 changed files with 2 additions and 0 deletions

View File

@ -63,6 +63,7 @@ fun Request.authorize(context: Context, oAuth: OAuth): Request {
Log.e("Request.authorize()", "performActionWithFreshToken failed: $e")
if (e.type != 2 || e.code != 2002) {
Log.e("Request.authorize()", Log.getStackTraceString(e))
EventBus.send(Event.LogOut)
}
}
if (token != old && token != null) {

View File

@ -103,6 +103,7 @@ class OAuth(private val authorizationServiceFactory: AuthorizationServiceFactory
if (e != null) {
Log.e("OAuth", "performTokenRequest failed: $e")
Log.e("OAuth", Log.getStackTraceString(e))
EventBus.send(Event.LogOut)
} else {
state.apply {
Log.i("OAuth", "applying new authState")