Browse Source

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>
develop
Hugh Daschbach 9 months ago committed by Marge
parent
commit
6f24535b79
  1. 1
      app/src/main/java/audio/funkwhale/ffa/utils/Extensions.kt
  2. 1
      app/src/main/java/audio/funkwhale/ffa/utils/OAuth.kt

1
app/src/main/java/audio/funkwhale/ffa/utils/Extensions.kt

@ -63,6 +63,7 @@ fun Request.authorize(context: Context, oAuth: OAuth): Request { @@ -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) {

1
app/src/main/java/audio/funkwhale/ffa/utils/OAuth.kt

@ -103,6 +103,7 @@ class OAuth(private val authorizationServiceFactory: AuthorizationServiceFactory @@ -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")

Loading…
Cancel
Save