Closed CharlesLueng closed 2 years ago
存在此问题,同上:)
临时解决方案: 1、修改SSCMS/Repoistories/IAdministratorRepository.Cache.cs的第8行,第12行为:
Task<Administrator> GetByAccountAsync(string account, bool useCache = true);
Task<Administrator> GetByUserNameAsync(string userName, bool useCache = true);
2、修改SSCMS.Core/Repoistories/AdministratorRepository.Cache.cs的第57行
public async Task<Administrator> GetByAccountAsync(string account, bool useCache = true)
{
var admin = await GetByUserNameAsync(account, useCache);
if (admin != null) return admin;
if (StringUtils.IsMobile(account)) return await GetByMobileAsync(account);
if (StringUtils.IsEmail(account)) return await GetByEmailAsync(account);
return null;
}
3、修改SSCMS.Core/Repoistories/AdministratorRepository.Cache.cs的第89行
public async Task<Administrator> GetByUserNameAsync(string userName, bool useCache = true)
{
if (string.IsNullOrWhiteSpace(userName)) return null;
if (useCache)
{
return await GetAsync(Q
.Where(nameof(Administrator.UserName), userName)
.CachingGet(GetCacheKeyByUserName(userName))
);
}
return await GetAsync(Q
.Where(nameof(Administrator.UserName), userName)
.CachingRemove(GetCacheKeyByUserName(userName))
.CachingGet(GetCacheKeyByUserName(userName)));
}
4、修改SSCMS.Core/Repoistories/AdministratorRepository.cs的第533行
var administrator = await GetByAccountAsync(account, false);
完成修改。原理,登录检测不从缓存中获取(缓存会存在null)的情况,
似乎到目前为止7.1还是有这个问题,请官方注意。
系统登录的时候,需要登录2次才能正常登录进来。看了代码是因为登录的时候取出来的用户信息缓存里面不存在验证密码所需要的字段,导致如果用户缓存已存在的情况下需要登录失败一次,移除了用户缓存后,再登录,就会去数据库里取用户信息来校验