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:
toast = "Login failed, try again";
break;
case SelectorNetClient.TokenResponseStatus.ExpiredCreds:
toast = "Credentials expired, try again";
break;
case SelectorNetClient.TokenResponseStatus.OK:
logger.LogInformation("Login succeeded, redirecting");
navigation.NavigateTo("/app");

View File

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

View File

@ -70,6 +70,14 @@ public class SessionManager
case SelectorNetClient.TokenResponseStatus.UserSearchFailed:
_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;
case SelectorNetClient.TokenResponseStatus.BadCreds:
_logger.LogInformation("Token request failed, bad password");