示例#1
0
 public ClientJsonResult SignOut(TokenUserClient tokenUser)
 {
     if (tokenUser != null)
     {
         IAccountDriver driver = DependencyResolver.Current.GetService <IAccountDriver>();
         driver.TrySignOut(tokenUser);
         FormsAuthentication.SignOut();
         tokenUser.AddSuccessNotification(MessageManager.GetMessage(OperationStatus.SignOutSuccess));
     }
     else
     {
         tokenUser = new TokenUserClient();
         tokenUser.AddErrorNotification(MessageManager.GetMessage(OperationStatus.DataFormatError));
     }
     return(ClientJson(tokenUser));
 }
示例#2
0
        public ClientJsonResult SignIn(UserSignInClient signInUser)
        {
            if (signInUser != null)
            {
                try
                {
                    signInUser.ClearNotifications();
                    IAccountDriver  driver = DependencyResolver.Current.GetService <IAccountDriver>();
                    TokenUser       tokenUser;
                    OperationStatus status = driver.TrySignIn(signInUser, out tokenUser);
                    if (status == OperationStatus.SignInSuccess)
                    {
                        SaveTicketToCookie(tokenUser, signInUser.IsCookiePersistent);
                        TokenUserClient clientTokenUser = new TokenUserClient(tokenUser);
                        clientTokenUser.AddSuccessNotification(MessageManager.GetMessage(status));
                        return(ClientJson(clientTokenUser));
                    }
                    else
                    {
                        signInUser.ServerStatus = false;
                        signInUser.AddErrorNotification(MessageManager.GetMessage(status));
                    }
                }
                catch (Exception ex)
                {
                    signInUser.ServerStatus = false;
                    LoggingWork.Error(ex);
                    signInUser.AddErrorNotification(MessageManager.GetMessage(OperationStatus.GenericError));
                }
            }
            else
            {
                signInUser = new UserSignInClient()
                {
                    ServerStatus = false
                };
                signInUser.AddErrorNotification(MessageManager.GetMessage(OperationStatus.DataFormatError));
            }

            return(ClientJson(signInUser));
        }