用户限制修改
parent
b550d940df
commit
d29cc43b15
|
@ -76,7 +76,7 @@ namespace IRaCIS.Core.API
|
|||
options.Filters.Add<ProjectExceptionFilter>();
|
||||
options.Filters.Add<UnitOfWorkFilter>();
|
||||
|
||||
//options.Filters.Add<LimitUserRequestAuthorization>();
|
||||
options.Filters.Add<LimitUserRequestAuthorization>();
|
||||
|
||||
})
|
||||
.AddDataAnnotationsLocalization(options => {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
using IRaCIS.Core.Domain.Share;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
|
@ -45,11 +44,11 @@ public class LimitUserRequestAuthorization : IAsyncAuthorizationFilter
|
|||
|
||||
|
||||
//2、在这里取缓存 进行比较 看是否有其他人进行了登陆,如果其他人登陆了,就把之前用户挤掉
|
||||
|
||||
var cacheUserToken = (await _provider.GetAsync<string>(_userInfo.Id.ToString())).Value;
|
||||
|
||||
if (cacheUserToken == null)
|
||||
if (string.IsNullOrWhiteSpace(cacheUserToken))
|
||||
{
|
||||
|
||||
//设置当前用户最新Token
|
||||
await _provider.SetAsync(_userInfo.Id.ToString(), _userInfo.UserToken, TimeSpan.FromDays(7));
|
||||
|
||||
|
@ -69,23 +68,7 @@ public class LimitUserRequestAuthorization : IAsyncAuthorizationFilter
|
|||
//context.Result = new StatusCodeResult(401);
|
||||
}
|
||||
|
||||
//var cacheHostToken = (await _provider.GetAsync<string>(_userInfo.IP.ToString()+_userInfo.LocalIp.ToString())).Value;
|
||||
|
||||
//if (cacheHostToken == null)
|
||||
//{
|
||||
// //设置当前主机最新Token
|
||||
// await _provider.SetAsync(_userInfo.IP.ToString() + _userInfo.LocalIp.ToString(), _userInfo.UserToken, TimeSpan.FromDays(7));
|
||||
|
||||
//}
|
||||
////是同主机
|
||||
//else if (cacheHostToken == _userInfo.UserToken)
|
||||
//{
|
||||
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// context.Result = new StatusCodeResult(401);
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,18 +92,6 @@ namespace IRaCIS.Application.Services
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//正则 至少8个字符,至少1个大写字母,1个小写字母,1个数字和1个特殊字符:
|
||||
//^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,}
|
||||
|
||||
if (!Regex.IsMatch(newPwd, @"^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[_.@])[A-Za-z0-9_.@$!%*?&]{10,}"))
|
||||
{
|
||||
|
||||
throw new BusinessValidationFailedException("密码至少10个字符,且包括至少1个大写字母,1个小写字母,1个数字和1个特殊字符");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
await Task.CompletedTask;
|
||||
|
|
|
@ -158,7 +158,24 @@ namespace IRaCIS.Core.Domain.Share
|
|||
{
|
||||
get
|
||||
{
|
||||
return _accessor?.HttpContext?.Request.Headers["Authorization"].ToString()?.Substring(7);
|
||||
|
||||
var authorizationHeader = _accessor?.HttpContext?.Request.Headers["Authorization"].ToString();
|
||||
if (!string.IsNullOrWhiteSpace(authorizationHeader))
|
||||
{
|
||||
return authorizationHeader.Substring(7);
|
||||
|
||||
}
|
||||
|
||||
var token = _accessor?.HttpContext?.Request.Query["access_token"].ToString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(token))
|
||||
{
|
||||
return token;
|
||||
|
||||
}
|
||||
return string.Empty;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue