adding forbidden and expired creds handling

This commit is contained in:
Andy Pack 2024-02-23 08:38:19 +00:00
parent 1cda3fe182
commit 054b63c292
Signed by: sarsoo
GPG Key ID: A55BA3536A5E0ED7
3 changed files with 16 additions and 2 deletions

View File

@ -45,6 +45,9 @@
case SelectorNetClient.TokenResponseStatus.BadCreds: case SelectorNetClient.TokenResponseStatus.BadCreds:
toast = "Login failed, try again"; toast = "Login failed, try again";
break; break;
case SelectorNetClient.TokenResponseStatus.ExpiredCreds:
toast = "Credentials expired, try again";
break;
case SelectorNetClient.TokenResponseStatus.OK: case SelectorNetClient.TokenResponseStatus.OK:
logger.LogInformation("Login succeeded, redirecting"); logger.LogInformation("Login succeeded, redirecting");
navigation.NavigateTo("/app"); navigation.NavigateTo("/app");

View File

@ -81,6 +81,9 @@ public class SelectorNetClient : ISelectorNetClient
case HttpStatusCode.Unauthorized: case HttpStatusCode.Unauthorized:
ret.Status = TokenResponseStatus.BadCreds; ret.Status = TokenResponseStatus.BadCreds;
break; break;
case HttpStatusCode.Forbidden:
ret.Status = TokenResponseStatus.ExpiredCreds;
break;
case HttpStatusCode.OK: case HttpStatusCode.OK:
ret.Status = TokenResponseStatus.OK; ret.Status = TokenResponseStatus.OK;
ret.Token = result.Content.ReadFromJsonAsync<TokenNetworkResponse>().Result.Token; ret.Token = result.Content.ReadFromJsonAsync<TokenNetworkResponse>().Result.Token;
@ -107,7 +110,7 @@ public class SelectorNetClient : ISelectorNetClient
public enum TokenResponseStatus public enum TokenResponseStatus
{ {
Malformed, UserSearchFailed, BadCreds, OK Malformed, UserSearchFailed, BadCreds, ExpiredCreds, OK
} }
private class TokenModel private class TokenModel

View File

@ -70,6 +70,14 @@ public class SessionManager
case SelectorNetClient.TokenResponseStatus.UserSearchFailed: case SelectorNetClient.TokenResponseStatus.UserSearchFailed:
_logger.LogInformation("Token request failed, no user by that name"); _logger.LogInformation("Token request failed, no user by that name");
break;
case SelectorNetClient.TokenResponseStatus.ExpiredCreds:
_logger.LogInformation("Token expired, log back in");
lastStoredKey = null;
lastRefresh = DateTime.Now;
Preferences.Default.Remove(Constants.JwtPrefKey);
break; break;
case SelectorNetClient.TokenResponseStatus.BadCreds: case SelectorNetClient.TokenResponseStatus.BadCreds:
_logger.LogInformation("Token request failed, bad password"); _logger.LogInformation("Token request failed, bad password");