| | |
| | | |
| | | public async Task<int> LoginAdmin(string loginName, string loginPwd) |
| | | { |
| | | //查询密码已错误次数 |
| | | string pwdErrNumSql = $@"select PwdErrNum from SysUserInfor where UserName='{loginName}'"; |
| | | int pwdErrNum = Db.Ado.GetInt(pwdErrNumSql); |
| | | //设定密码错误的次数 |
| | | string funNumSql = $@"select SetValue from SysFunSetting where IsDel='0' and IsEnable='NO' and FunSetNo='pwdErrNum' and GroupNo='pwdErrNum'"; |
| | | int funNum = Db.Ado.GetInt(funNumSql); |
| | | |
| | | //比较设定次数和已错误次数 |
| | | if (pwdErrNum < funNum) |
| | | { |
| | | //loginPwd = Md5Tools.CalcMd5(loginPwd); |
| | | var modUser = await Db.Queryable<SysUserInfor>().FirstAsync(m => m.UserName == loginName && m.PassWord == loginPwd &&m.IsDel=="0"); |
| | | if (modUser != null) //账号密码是否正确 |
| | | { |
| | | if (modUser.Status == "0") //当前账号是否正常启用 |
| | | { |
| | | //密码错误次数+1 |
| | | string uptErrNumSql = $@"update SysUserInfor set PwdErrNum=0 where UserName='{loginName}'"; |
| | | int uptErrNum = Db.Ado.ExecuteCommand(uptErrNumSql); |
| | | |
| | | //最后登陆时间 |
| | | await Db.Updateable(modUser).UpdateColumns(s => s.LoginTime == DateTime.Now).ExecuteCommandAsync(); |
| | | return modUser.Id; |
| | |
| | | } |
| | | else //账号密码不正确或没有此账号 |
| | | { |
| | | //密码错误次数+1 |
| | | string addErrNumSql = $@"update SysUserInfor set PwdErrNum+=1 where UserName='{loginName}'"; |
| | | int addErrNum = Db.Ado.ExecuteCommand(addErrNumSql); |
| | | |
| | | return -1; |
| | | } |
| | | } |
| | | else//锁定账号 |
| | | { |
| | | return -2; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取用户角色信息 |