public async Task <ActionResult> GetUserRoleData(string userId)
        {
            var poolId    = Client.SecurityPoolId;
            var userRoles = await _poolManager.GetUserRolesAsync(poolId, userId);

            return(Json(userRoles));
        }
        public async Task <IActionResult> Profile()
        {
            var siteContext = _siteContextAccessor.GetContext();

            var userId               = User.GetUserId();
            var siteSecurityPoolId   = siteContext.SecurityPoolId;
            var clientSecurityPoolId = siteContext.Client.SecurityPoolId;
            var thisUser             = await _userManager.GetUserAsync(userId);

            var userSiteRoles = await _poolManager.GetUserRolesAsync(siteSecurityPoolId, userId);

            var userClientRoles = await _poolManager.GetUserRolesAsync(clientSecurityPoolId, userId);

            var userCorpRoles = await _poolManager.GetUserRolesAsync("MyCompany-corp-pool", userId);

            //TODO: pull in user claims (permissions)
            var model = thisUser.ProjectTo <UserProfileViewModel>();

            model.SiteRoles   = userSiteRoles;
            model.ClientRoles = userClientRoles;
            model.CorpRoles   = userCorpRoles;

            var providers = await _userManager.GetWirelessProvidersAsync();

            model.WirelessProviderId = model.WirelessProviderId == null ? "" : providers.FirstOrDefault(p => p.Id == model.WirelessProviderId).Name;


            return(View(model));
        }
Exemple #3
0
        public async Task <IViewComponentResult> InvokeAsync(string siteId, string userId)
        {
            var site = await _siteManager.GetByIdAsync(siteId);

            var allRoles = await _poolManager.GetRolesAsync(site.SecurityPoolId);

            var userRoles = await _poolManager.GetUserRolesAsync(site.SecurityPoolId, userId);

            // TODO - Ensure user's directory is mapped to this site's security pool

            var model = allRoles.Select(x => new UserRoleViewModel
            {
                RoleId   = x.Id,
                RoleName = x.Name,
                Selected = userRoles.Any(y => y.Id == x.Id)
            }).ToList();

            ViewData["UserId"] = userId;

            return(View(model));
        }