コード例 #1
0
        public JsonResult Login(string account = "", string password = "")
        {
            var info = _sysAccountService.Login(account, MD5Util.GetMD5_32(password));

            if (info == null)
            {
                //无此账号信息
                return(Json(new { Status = -1 }, JsonRequestBehavior.AllowGet));
            }
            if (info.Status == 0)
            {
                //该账号被禁用
                return(Json(new { Status = -2 }, JsonRequestBehavior.AllowGet));
            }
            var imgInfo = info.BaseImage ?? new Domain.Model.BaseImage();

            //缓存用户信息
            SessionHelper.Add(LoginerConst.ACCOUNT_ID, info.SysAccountId.ToString());
            SessionHelper.Add(LoginerConst.ACCOUNT, info.Account);
            SessionHelper.Add(LoginerConst.NICKNAME, info.NickName);
            SessionHelper.Add(LoginerConst.ACCOUNT_IMG, imgInfo.Source + imgInfo.Path);
            SessionHelper.Add(LoginerConst.ROLE_ID, info.SysRoleId.ToString());
            SessionHelper.Add(LoginerConst.BUSINESS_ID, info.BusinessInfoId.ToString());
            return(Json(new { Status = 1 }, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public async Task <JsonResult> Login(string userName, string password, string code)
        {
            OperateResult <string> result = new OperateResult <string>();
            string verifyCode             = HttpContext.Session.GetString("VerifyCode");

            if (verifyCode == null)
            {
                result.Message = "验证码已过期";
            }
            else if (code.ToLower() != verifyCode.ToString().ToLower())
            {
                result.Message = "验证码有误";
            }
            else
            {
                //清除验证码
                HttpContext.Session.Remove("VerifyCode");
                var operateResult      = _sysAccountService.Login(userName, password);
                AuthorizationUser auth = operateResult.Data;
                if (auth != null)
                {
                    await AuthenticationHelper.SetAuthCookie(auth);

                    result.Status = ResultStatus.Success;
                    result.Data   = "/Main/Home/Index";

                    #region 记录登录日志
                    LoginLogHandler loginLog = new LoginLogHandler(auth.LoginId);
                    loginLog.WriteLog();
                    #endregion
                }
                result.Message = operateResult.Message;
            }
            return(Json(result));
        }
コード例 #3
0
        public IActionResult Lock(string pwd)
        {
            var           data   = _sysAccountService.Login(CurrentUser.UserName, pwd);
            OperateResult result = new OperateResult();

            result.Status  = data.Status;
            result.Message = data.Message;
            return(Json(result));
        }
コード例 #4
0
        public ResponseModel <BCSysAccountDTO> Login(BCLoginDTO bcloginDTO)
        {
            var result = new ResponseModel <BCSysAccountDTO>();
            var data   = new BCSysAccountDTO();

            result.error_code = Result.SUCCESS;
            result.message    = "";
            var info = _sysAccountService.Login(bcloginDTO.account, bcloginDTO.password);//.SysBusinessAccount(sysBusinessAccountLoginDto.account, sysBusinessAccountLoginDto.password);

            if (info == null || info.SysAccountId <= 0)
            {
                result.error_code = Result.ERROR;
                result.message    = "您输入的帐号或密码错误,请重新输入";
                result.data       = data;
                return(result);
            }
            else
            {
                DateTime time = System.DateTime.Now;
                if (info.LoginTime.AddMonths(1) < System.DateTime.Now || string.IsNullOrWhiteSpace(info.Token))//过期
                {
                    string tokenstr = MD5Util.GetMD5_32(info.PassWord + info.SysAccountId + time.ToString("yyyy:MM:dd HH:mm:ss") + token_key);
                    data.last_loin_time          = info.LoginTime.ToString("yyyy:MM:dd HH:mm:ss");
                    data.nick_name               = info.NickName;
                    data.path                    = info.BaseImage == null ? "" : info.BaseImage.Source + info.BaseImage.Path;
                    data.phone_no                = info.MobilePhone;
                    data.sys_business_account_id = info.BusinessInfoId;
                    data.token_str               = tokenstr;
                    data.account                 = info.Account;
                    info.Token                   = tokenstr;
                    info.LoginTime               = time;
                    _sysAccountService.Update(info);
                    result.data = data;
                }
                else
                {
                    data.last_loin_time          = info.LoginTime.ToString("yyyy:MM:dd HH:mm:ss");
                    data.nick_name               = info.NickName;
                    data.path                    = info.BaseImage == null ? "" : info.BaseImage.Source + info.BaseImage.Path;
                    data.phone_no                = info.MobilePhone;
                    data.sys_business_account_id = info.BusinessInfoId;
                    data.token_str               = info.Token;
                    data.account                 = info.Account;
                    info.LoginTime               = System.DateTime.Now;
                    _sysAccountService.Update(info);
                    result.data = data;
                }
            }
            return(result);
        }
コード例 #5
0
        public JsonResult EditPwd(int accountId, string account, string oldPassword, string newPassword)
        {
            try
            {
                //获取用户
                var _user = _SysAccountService.Login(account, MD5Util.GetMD5_32(oldPassword));
                if (_user == null)
                {
                    //获取用户失败
                    return(Json(new { Status = Successed.Empty }, JsonRequestBehavior.AllowGet));
                }
                _user.PassWord = MD5Util.GetMD5_32(newPassword);
                //修改密码
                _SysAccountService.Update(_user);

                //修改密码成功,清除缓存
                Loginer.DelAccountCache();
                return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet));
            }
        }