Ejemplo n.º 1
0
        private string GetClaimsForUser(HttpActionContext actionContext)
        {
            var repository = (IRepository <User>)actionContext.Request.GetDependencyScope().GetService(typeof(IRepository <User>));

            var loggedInUser = new ExtractLoggedInUser(actionContext.Request.GetOwinContext().Authentication.User, repository)
                               .Do();

            return(loggedInUser.NotAny() || loggedInUser.Single().Claims.IsNullOrWhiteSpace()
                ? ""
                : loggedInUser.Single().Claims);
        }
Ejemplo n.º 2
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            var repository = (IRepository <User>)actionContext.Request.GetDependencyScope().GetService(typeof(IRepository <User>));

            var loggedInUser = new ExtractLoggedInUser(actionContext.Request.GetOwinContext().Authentication.User, repository).Do();

            if (loggedInUser.Any())
            {
                var currentUser = (ICurrentUser)actionContext.Request.GetDependencyScope().GetService(typeof(ICurrentUser));
                currentUser.Id = loggedInUser.Single().Id;
            }
        }