public async Task <IResponseOutput> LoginAsync(AuthLoginInput input) { var user = (await _userRepository.GetAsync(a => a.UserName == input.UserName)); if (!(user?.Id > 0)) { return(ResponseOutput.NotOk("账号输入有误!", 3)); } #region 解密 if (input.PasswordKey.NotNull()) { var passwordEncryptKey = string.Format(CacheKey.PassWordEncryptKey, input.PasswordKey); var existsPasswordKey = await _cache.ExistsAsync(passwordEncryptKey); if (existsPasswordKey) { var secretKey = await _cache.GetAsync(passwordEncryptKey); if (secretKey.IsNull()) { return(ResponseOutput.NotOk("解密失败!", 1)); } input.Password = DesEncrypt.Decrypt(input.Password, secretKey); await _cache.DelAsync(passwordEncryptKey); } else { return(ResponseOutput.NotOk("解密失败!", 1)); } } #endregion var password = Md5Encrypt.Encrypt32(input.Password); if (user.Password != password) { return(ResponseOutput.NotOk("密码输入有误!", 4)); } var authLoginOutput = _mapper.Map <AuthLoginOutput>(user); return(ResponseOutput.Ok(authLoginOutput)); }