示例#1
0
 public OperationStatus TrySignOut(TokenUserClient clientTokenUser)
 {
     try
     {
         if (clientTokenUser == null)
         {
             return(OperationStatus.NotValidUser);
         }
         if (SecurityManager.VerifyToken(clientTokenUser.UserName, clientTokenUser.Token))
         {
             SecurityManager.RemoveTokenUser(clientTokenUser.UserName);
         }
         else
         {
             return(OperationStatus.NotValidUser);
         }
         clientTokenUser.Reset();
         clientTokenUser.ServerStatus = true;
         return(OperationStatus.SignOutSuccess);
     }
     catch
     {
         clientTokenUser.ServerStatus = false;
         return(OperationStatus.GenericError);
     }
 }
示例#2
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));
 }
示例#3
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));
        }