adding forbidden and expired creds handling
This commit is contained in:
parent
1cda3fe182
commit
054b63c292
@ -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");
|
||||||
|
@ -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
|
||||||
|
@ -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");
|
||||||
|
Loading…
Reference in New Issue
Block a user