public async Task Invoke(HttpContext context, IJwtAuthenticationService authenticateService) { if (!IsNullOrWhiteSpace(authenticateService .CheckTokenValidate(context.Session.GetString("Token")))) { var currentUser = context.Session.Get <User>("CurrentUser"); var userPermissions = ApiExtension.PostAsync <IEnumerable <Permission>, RequestParameters>( GlobalParameter.ApiBaseAddress, "/api/User/GetUserAllPermissions", new RequestParameters { Param1 = currentUser.Id, Param2 = currentUser.SoftwareId, }, context.Session.GetString("Token")).Result; if (userPermissions.All(p => !string.Equals(p.Action, context.Request.Path.ToString(), StringComparison.CurrentCultureIgnoreCase))) { context.Response.Redirect($"{context.Request.Scheme}://" + $"{context.Request.Host}/Identity/User/Profile"); } await _next.Invoke(context); } else { context.Response.Redirect($"{context.Request.Scheme}://{context.Request.Host}/Home/Login"); } }
public async Task Invoke(HttpContext context, IJwtAuthenticationService authenticateService) { if (!string.IsNullOrWhiteSpace(authenticateService .CheckTokenValidate(context.Request.Headers["Security-Token"]))) { await _next.Invoke(context); } else { context.Response.Redirect($"{context.Request.Scheme}://{context.Request.Host}/Home/Login"); } }