Beispiel #1
0
        public static LoginPageState LoginResultReducer(LoginPageState state, LoginResultAction action)
        {
            state.IsLoggingIn = false;

            if (action.LoginResult.ApiResult == ApiResult.Ok)
            {
                return(new LoginPageState
                {
                    SuccessLogin = true
                });
            }

            if (action.LoginResult.ApiResult == ApiResult.Unknown)
            {
                state.ServerError = TextResources.ServerException;

                return(state);
            }
            switch (action.LoginResult.Error.ErrorType)
            {
            case ErrorType.EmailWrong:
            case ErrorType.NameWrong:
                state.NameOrEmailError = TextResources.EmailWrong;
                return(state);

            case ErrorType.PasswordWrong:
                state.PasswordError = TextResources.PasswordWrong;
                return(state);
            }
            state.ServerError = action.LoginResult.Error.Message;
            return(state);
        }
Beispiel #2
0
     public static CurrentUser LoginResultReducer(CurrentUser preCurrentUser, LoginResultAction action)
     {
         if (action.LoginResult.ApiResult == ApiResult.Ok)
         {
             return new CurrentUser
                    {
                        IsAuthenticated   = true,
                        MobileServiceUser = new MobileServiceUser(action.LoginResult.Data.User.Id)
                        {
                            MobileServiceAuthenticationToken = action.LoginResult.Data.AuthenticationToken
                        },
                        User = action.LoginResult.Data.User
                    }
         }
         ;
         return(preCurrentUser);
     }
 }
Beispiel #3
0
 public static LoginState ReduceGetArticlesResultAction(LoginState state, LoginResultAction action)
 => new LoginState(action.Username, action.Token, true);