Exemplo n.º 1
0
        public ActionResult SignIn(string returnUrl, string loginName, string password, bool?rememberMe)
        {
            var response = new AjaxResponse();

            if (loginName.Trim() == "" || password.Trim() == "")
            {
                response.Succeeded    = false;
                response.ErrorMessage = "用户名或密码不能为空。";
                return(Json(response));
            }

            try
            {
                AuthorizeManager.SignIn(loginName, password, rememberMe.HasValue && rememberMe.Value);
                response.Succeeded   = true;
                response.RedirectUrl = returnUrl;
                response.ShowMessage = true;
                response.Message     = MessagesResources.Login_Success;
            }
            catch (Exception ex)
            {
                if (!(ex is DefinedException))
                {
                    Log.Error(ex.GetIndentedExceptionLog());
                }
                response.Succeeded    = false;
                response.ErrorMessage = ex.Message;
                response.ShowMessage  = true;
            }
            return(Json(response));
        }
Exemplo n.º 2
0
        public ActionResult SignIn(string ReturnUrl, string LoginName, string PassWord, string Code, bool?rememberMe = true)
        {
            var response = new AjaxResponse();

            try
            {
                AuthorizeManager.SignIn(LoginName, PassWord, rememberMe.Value);
                response.Succeeded   = true;
                response.RedirectUrl = "";
            }
            catch (Exception ex)
            {
                if (!(ex is DefinedException))
                {
                    Log.Error(ex.GetIndentedExceptionLog());
                }
                response.Succeeded    = false;
                response.ErrorMessage = ex.Message;
                response.ShowMessage  = true;
            }
            return(Json(response));
        }