コード例 #1
0
        public ClaimsIdentityModel GetCurrentUser()
        {
            if (CurrentUser == null)
            {
                return(null);
            }
            Mapper.Initialize(cfg => {
                cfg.CreateMap <ApplicationUser, ClaimsIdentityModel>();
                cfg.CreateMap <RoleClaim, ClaimModel>();
            });
            ClaimsIdentityModel result = Mapper.Map <ClaimsIdentityModel>(CurrentUser);

            result.Claims = AccountQueries.GetClaimsDictionaryByUser(CurrentUser, this.DbContext);
            return(result);
        }
コード例 #2
0
        public bool CheckAuthentication(HttpActionContext actionContext)
        {
            WebController controller = (WebController)actionContext.ControllerContext.Controller;

            if (controller.CurrentUser == null)
            {
                return(false);
            }
            Dictionary <string, string> dClaims = AccountQueries.GetClaimsDictionaryByUser(controller.CurrentUser, controller.DbContext);
            bool result = true;

            this.Claims.ToList().ForEach(c =>
            {
                result = dClaims[c] == "true" && result;
            });
            return(result);
        }