Esempio n. 1
0
		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);
		}
Esempio n. 2
0
        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);
        }