public async Task Invoke(HttpContext context, IRequestService requestService) { var dbCtx = DbContext.CreateContext(Settings.ConnectionString); requestService.AddObjectToDispose(dbCtx); WebSecurityUtil.Authenticate(context); var identity = (context.User as ErpPrincipal)?.Identity as ErpIdentity; if (identity != null) { var securityContext = SecurityContext.OpenScope(identity.User); requestService.AddObjectToDispose(securityContext); } await next(context); }
public async Task Invoke(HttpContext context, IRequestService requestService) { var dbCtx = DbContext.CreateContext(Settings.ConnectionString); requestService.AddObjectToDispose(dbCtx); WebSecurityUtil.Authenticate(context); var identity = (context.User as ErpPrincipal)?.Identity as ErpIdentity; if (identity != null) { var securityContext = SecurityContext.OpenScope(identity.User); requestService.AddObjectToDispose(securityContext); } await next(context); }