public static string EncryptText(string text, string passwordPhrase) { var aesEncrypted = AesEncrypt.EncryptText(text, passwordPhrase); var desEncrypted = DesEncrypt.EncryptString(aesEncrypted, passwordPhrase); return(desEncrypted); }
public async Task <BaseResponse> UserLoginAsync(LoginViewModel req) { BaseResponse br = new BaseResponse(); UserMessage rm = new UserMessage(); var UserInfo = await _user.FindWithGroup(a => a.Account == req.Account); if (UserInfo == null)//用户名不存在 { br.Success = false; br.Message = "用户名不存在"; return(br); } string p = EncryptData.EncryptPassword(req.Password, UserInfo.Salt); if (p != UserInfo.Password) //密码不正确 { br.Success = false; br.Message = "密码不正确"; return(br); } if (UserInfo.Status == UserStatus.InActive) { br.Success = false; br.Message = "该账号未激活,请联系管理员激活"; return(br); } if (UserInfo.Status == UserStatus.InValid) { br.Success = false; br.Message = "该账号为无效账号"; return(br); } if (UserInfo.GroupId == null) //用户没有加入组织 { br.Success = false; br.Message = "用户没有加入组织,不能登录"; return(br); } //else //{ // rm.GroupId = UserInfo.GroupId; // rm.GroupName = UserInfo.Group.GroupName; //} rm = _mapper.Map <UserMessage>(UserInfo); //获取用户的角色 var r = await _userRole.FindWithRole(UserInfo.Id); if (r != null) { rm.Roles = r.Select(a => a.RoleId).ToString(); foreach (var item in r) { if (item.Role.IsAdmin) { rm.IsAdmin = true; break; } } } rm.Dt = DateTime.Now; string strUser = JsonConvert.SerializeObject(rm); br = new UserloginResponse() { Success = true, Message = "用户登录成功", Token = DesEncrypt.EncryptString(strUser) }; return(br); //new UserloginResponse() { Success = true, Message = "dfdfdfdsd", Token = @"B13F8398D170A45F0475461C9422629F2069ED228911C87A669C8F16AE78524620F5348EB0261C5ADBF35C761A65ADDF74B0D7800241F4B8346DDEE16E40E3F548DC9D9F63BCDB24FB0A0AB33AC858C8F4718F9A4134D28F155C8EDAC2909FAD30B2CCB4782D3E62EEB05101F767BC5C9EEDF8C927CF7DA5CA7A7A9FA6375BA3F8FF93928278D5E4A75DE73E77E0FB21840A5DEC384DFBAFE03303F4E5203116C92542AD5849293DA0E9A100A5FFB221F779FF2E4B73281481CFAFF8200BDBF0C2470A236D1CCD3B170524ECEB471208AE8EC02A9334DD25228D932E7BFFE142CEBD40296B248780" }; }