修改用户权限校验
							parent
							
								
									8d3e892216
								
							
						
					
					
						commit
						0cfc8fc37b
					
				| 
						 | 
					@ -35,27 +35,43 @@ public class LimitUserRequestAuthorization : IAsyncAuthorizationFilter
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (context.ActionDescriptor.EndpointMetadata.Any(item => item is IAllowAnonymous))
 | 
					            if (context.ActionDescriptor.EndpointMetadata.Any(item => item is IAllowAnonymous))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
                //匿名访问的不处理
 | 
					                //匿名访问的不处理
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                //1、用户登陆的时候,设置缓存
 | 
					                //1、用户登陆的时候,设置缓存
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //没有从请求中取到token
 | 
				
			||||||
 | 
					                if (string.IsNullOrWhiteSpace(_userInfo.UserToken))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    context.HttpContext.Response.ContentType = "application/json";
 | 
				
			||||||
 | 
					                    context.HttpContext.Response.StatusCode = StatusCodes.Status200OK;
 | 
				
			||||||
 | 
					                    await context.HttpContext.Response.WriteAsync(JsonConvert.SerializeObject(ResponseOutput.NotOk("当前请求未从Header/Url取到Token")));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //2、在这里取缓存  进行比较  看是否有其他人进行了登陆,如果其他人登陆了,就把之前用户挤掉
 | 
					                //2、在这里取缓存  进行比较  看是否有其他人进行了登陆,如果其他人登陆了,就把之前用户挤掉
 | 
				
			||||||
                var cacheUserToken = (await _provider.GetAsync<string>(_userInfo.Id.ToString())).Value;
 | 
					                var cacheUserToken = (await _provider.GetAsync<string>(_userInfo.Id.ToString())).Value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //缓存中没有取到Token
 | 
				
			||||||
                if (string.IsNullOrWhiteSpace(cacheUserToken))
 | 
					                if (string.IsNullOrWhiteSpace(cacheUserToken))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    //设置当前用户最新Token
 | 
					                    //设置当前用户最新Token
 | 
				
			||||||
                    await _provider.SetAsync(_userInfo.Id.ToString(), _userInfo.UserToken, TimeSpan.FromDays(7));
 | 
					                    await _provider.SetAsync(_userInfo.Id.ToString(), _userInfo.UserToken, TimeSpan.FromDays(7));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    cacheUserToken = _userInfo.UserToken;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                //是同一个人  
 | 
					                //是同一个人  
 | 
				
			||||||
                else if (cacheUserToken == _userInfo.UserToken)
 | 
					                else if (cacheUserToken == _userInfo.UserToken)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -283,7 +283,7 @@ namespace IRaCIS.Core.Application.Contracts
 | 
				
			||||||
                        TrialSiteSurveyId = dbEntity!.Id,
 | 
					                        TrialSiteSurveyId = dbEntity!.Id,
 | 
				
			||||||
                        Token = _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo()
 | 
					                        Token = _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo()
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            Id = Guid.Empty,
 | 
					                            Id = Guid.NewGuid(),
 | 
				
			||||||
                            IsReviewer = false,
 | 
					                            IsReviewer = false,
 | 
				
			||||||
                            IsAdmin = false,
 | 
					                            IsAdmin = false,
 | 
				
			||||||
                            RealName = "SiteSurvey",
 | 
					                            RealName = "SiteSurvey",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue