Beispiel #1
0
        [ValidateAntiForgeryToken]//防伪标记 预防坏蛋攻击
        public IActionResult UserLogin(string username, string password)
        {
            var message = new ResponseModel();

            try
            {
                var sysUsers = injection.GetT <ISysUserBLL>().GetModelNoTracking(t =>
                                                                                 (t.UserName.Equals(username) ||
                                                                                  t.UserEmail.Equals(username) ||
                                                                                  t.UserPhone.Equals(username) && t.DeleteSign.Equals(1)));
                if (sysUsers == null)
                {
                    message.StateCode = StatesCode.failure;
                    message.Messages  = "该账户不存在";
                }
                else
                {
                    if (sysUsers.UserStatus.Equals((int)SysEnum.Enum_UserStatus.Status_Discontinuation))
                    {
                        message.StateCode = StatesCode.failure;
                        message.Messages  = "账户已停用,请联系管理员解除";
                    }
                    else if (!MD5Encrypt.Get32MD5Two(password).Equals(sysUsers.UserPwd))
                    {
                        message.StateCode = StatesCode.failure;
                        message.Messages  = "密码错误";
                    }
                    else
                    {
                        var user = injection.GetT <ISysUserBLL>().GetLoginSysUser(sysUsers).Data;
                        injection.GetT <UserAccount>().Login(user);
                        message.Messages = "登陆成功";
                        message.JsonData = new { baseUrl = "/Home/Index", UserId = sysUsers.UserId, tokenUuid = Guid.NewGuid().ToString() };
                    }
                }
            }
            catch (Exception er)
            {
                Log4netHelper.Error(this, er);
            }
            return(Json(message));
        }
Beispiel #2
0
        [ValidateAntiForgeryToken]//防伪标记 预防坏蛋攻击
        public IActionResult UserLogin(string username, string password)
        {
            var message  = new ResponseModel();
            var sysUsers = _sysUserBLL.GetModels(t =>
                                                 (t.UserName.Equals(username) ||
                                                  t.UserEmail.Equals(username) ||
                                                  t.UserPhone.Equals(username) && t.DeleteSign.Equals((int)DeleteSign.Sing_Deleted))
                                                 ).FirstOrDefault();

            if (sysUsers == null)
            {
                message.RetCode = StatesCode.failure;
                message.RetMsg  = "该账户不存在";
            }
            else
            {
                if (sysUsers.UserStatus.Equals((int)UserStatus.Status_Discontinuation))
                {
                    message.RetCode = StatesCode.failure;
                    message.RetMsg  = "账户已停用,请联系管理员解除(17783042962)";
                }
                else if (!MD5Encrypt.Get32MD5Two(password).Equals(sysUsers.UserPwd))
                {
                    message.RetCode = StatesCode.failure;
                    message.RetMsg  = "密码错误";
                }
                else
                {
                    var user = _sysUserBLL.GetLoginSysUser(sysUsers).Data;
                    _userAccount.Login(user);
                    message.RetMsg = "登陆成功";
                    message.Data   = new { BaseUrl = "/Home/Index" };
                }
            }
            return(Ok(message));
        }