protected internal virtual void OnAuthenticationRequired(UnAuthorizedException e) { if (AuthenticationRequired != null) { AuthenticationRequired(this, e); } }
public static ErrorResponse ToErrorResponse(this UnAuthorizedException e) { return(new ErrorResponse() { Code = e.Code, Message = e.Message }); }
private static async Task HandleUnAuthorizedHttpException(UnAuthorizedException httpException, Func <Task> func, Func <Task> successCallback, Func <System.Exception, Task> failCallback) { var accepted = false; if (accepted) { await Execute(func, successCallback, failCallback); } else { await failCallback(httpException); } }
public static Exception GetExceptionByStatusCode(this RemoteInvokeResultMessage message) { Exception exception = null; switch (message.StatusCode) { case StatusCode.BusinessError: exception = new BusinessException(message.ExceptionMessage); break; case StatusCode.CommunicationError: exception = new CommunicationException(message.ExceptionMessage); break; case StatusCode.RequestError: case StatusCode.CPlatformError: case StatusCode.UnKnownError: exception = new CPlatformException(message.ExceptionMessage, message.StatusCode); break; case StatusCode.DataAccessError: exception = new DataAccessException(message.ExceptionMessage); break; case StatusCode.UnAuthentication: exception = new UnAuthenticationException(message.ExceptionMessage); break; case StatusCode.UnAuthorized: exception = new UnAuthorizedException(message.ExceptionMessage); break; case StatusCode.UserFriendly: exception = new UserFriendlyException(message.ExceptionMessage); break; case StatusCode.ValidateError: exception = new ValidateException(message.ExceptionMessage); break; default: exception = new CPlatformException(message.ExceptionMessage, message.StatusCode); break; } return(exception); }
private static async Task HandleUnAuthorizedHttpException <TResult>(UnAuthorizedException httpException, Func <Task <TResult> > func, Func <TResult, Task> successCallback, Func <System.Exception, Task> failCallback) { //var employeeId = GlobalSettings.UserName; //var password = await SecureStorageHelpers.GetValue(GlobalSettings.PasswordKey); //if (GlobalSettings.UserInfo != null && GlobalSettings.RememberMe && !string.IsNullOrEmpty(employeeId) && !string.IsNullOrEmpty(password)) //{ // try // { // Device.BeginInvokeOnMainThread(async() => // { // var container = ((WPSTORE.App)Application.Current).Container; // var authService = (IAuthenticationService)container.Resolve(typeof(IAuthenticationService)); // var result = await authService.LoginAsync(employeeId, password); // if(result != null && result.Token != null) // { // await Execute(func, successCallback, failCallback); // } // else // { // Application.Current.MainPage = new LoginPage(); // } // }); // } // catch (Exception ex) // { // } //} //else //{ // Application.Current.MainPage = new LoginPage(); //} Application.Current.MainPage = new LoginPage(); }