コード例 #1
0
        public ActionResult LoginOut()
        {
            AuthMgr.Logout();
            AjaxResult result = new AjaxResult
            {
                Success = true
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult Login()
        {
            string userName   = Request["UserName"];
            string userPwd    = Request["UserPwd"];
            string keepalive  = Request["keepalive"];
            string verifyCode = Request["VerifyCode"];

            if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(userPwd))
            {
                throw new BusinessException("请输入账号或密码");
            }
            if (string.IsNullOrWhiteSpace(verifyCode))
            {
                throw new BusinessException("请输入验证码");
            }

            string encrptedPassword = AuthMgr.EncryptPassword(userPwd);
            var    user             = AuthMgr.Login(userName, encrptedPassword, verifyCode, !string.IsNullOrEmpty(keepalive) && keepalive.ToLower() == "true");

            if (user != null)
            {
                if (user.ExData != null && !user.ExData.ToString().Equals("0"))
                {
                    var company = CompanyService.LoadCompany((int)user.ExData, false);
                    if (company == null || company.CompanyStatus != Entity.CompanyStatus.Authenticated)
                    {
                        AuthMgr.Logout();
                        throw new BusinessException("您所在的公司还未认证!");
                    }
                    if (company != null && company.AccountSysNo.HasValue && company.AccountSysNo.Value != user.UserSysNo)
                    {
                        AuthMgr.Logout();
                        throw new BusinessException("您没有权限登录此系统!");
                    }
                }
            }

            // SystemUserService systemUserServic = new SystemUserService();
            //  var loginUser= systemUserServic.LoadSystemUserBySysNo(user.UserSysNo, Entity.ConstValue.ApplicationID);
            //  if (loginUser != null)
            //  {

            // user.ExData = loginUser.MasterSysNo;
            //CookieHelper.SaveCookie<AuthUserModel>(LOGIN_COOKIE, user, 7 * 24 * 60);
            // }
            //}
            AjaxResult result = new AjaxResult
            {
                Success = true
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <returns></returns>
        public ActionResult SavePwd()
        {
            string OldPassword = Request["OldPassword"];
            string new1        = Request["new1"];
            string new2        = Request["new2"];

            if (new1 != new2)
            {
                throw new BusinessException("您输入的新密码与确认密码不匹配 ");
            }
            string            encrptedPassword  = AuthMgr.EncryptPassword(OldPassword);
            string            encrptednew1      = AuthMgr.EncryptPassword(new1);
            SystemUserService systemUserService = new SystemUserService();

            systemUserService.ResetSystemUserPassword(CurrUser.UserName, encrptedPassword, encrptednew1, AuthMgr.GetApplicationKey());
            //Rpc.Call<int>("AuthService.ResetSystemUserPassword", CurrUser.UserName, encrptedPassword, encrptednew1, AuthMgr.GetApplicationKey());
            AuthMgr.Logout();
            return(Json(new AjaxResult {
                Success = true, Message = "修改成功"
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
 public ActionResult Logout()
 {
     AuthMgr.Logout();
     string returnurl = Request.QueryString["returnurl"];
     return Redirect(System.Configuration.ConfigurationManager.AppSettings["LoginUrl"] + "?returnurl=" + returnurl);
 }