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:
parent
467556d75c
commit
6f24535b79
|
@ -63,6 +63,7 @@ fun Request.authorize(context: Context, oAuth: OAuth): Request {
|
||||||
Log.e("Request.authorize()", "performActionWithFreshToken failed: $e")
|
Log.e("Request.authorize()", "performActionWithFreshToken failed: $e")
|
||||||
if (e.type != 2 || e.code != 2002) {
|
if (e.type != 2 || e.code != 2002) {
|
||||||
Log.e("Request.authorize()", Log.getStackTraceString(e))
|
Log.e("Request.authorize()", Log.getStackTraceString(e))
|
||||||
|
EventBus.send(Event.LogOut)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (token != old && token != null) {
|
if (token != old && token != null) {
|
||||||
|
|
|
@ -103,6 +103,7 @@ class OAuth(private val authorizationServiceFactory: AuthorizationServiceFactory
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
Log.e("OAuth", "performTokenRequest failed: $e")
|
Log.e("OAuth", "performTokenRequest failed: $e")
|
||||||
Log.e("OAuth", Log.getStackTraceString(e))
|
Log.e("OAuth", Log.getStackTraceString(e))
|
||||||
|
EventBus.send(Event.LogOut)
|
||||||
} else {
|
} else {
|
||||||
state.apply {
|
state.apply {
|
||||||
Log.i("OAuth", "applying new authState")
|
Log.i("OAuth", "applying new authState")
|
||||||
|
|
Loading…
Reference in New Issue