Esempio n. 1
0
        public async Task <IActionResult> ManageClaims(string id)
        {
            var user = await _userManage.FindByIdAsync(id);

            if (user == null)
            {
                return(Redirect("Index"));
            }
            //List<string> AllClaimTypeList = new List<string>
            //{
            //    "Edit Albums",
            //    "Edit Users",
            //    "Edit Roles",
            //    "Email"
            //};

            var userClaims = await _userManage.GetClaimsAsync(user);

            var claims = userClaims.Select(x => x.Type).ToList();
            var vm     = new ManageClaimsModel
            {
                UserId          = user.Id,
                AvailableClaims = claims
            };

            return(View(vm));
        }
Esempio n. 2
0
        public async Task <IActionResult> ManageClaims(ManageClaimsModel args)
        {
            var user = await _userManage.FindByIdAsync(args.UserId);

            if (user == null)
            {
                RedirectToAction("Index");
            }
            var claim  = new Claim(args.ClaimId, args.ClaimId);
            var result = await _userManage.AddClaimAsync(user, claim);

            if (result.Succeeded)
            {
                return(RedirectToAction("Edit", new { user.Id }));
            }
            ModelState.AddModelError(string.Empty, "编辑用户Claims出错");
            return(View(user));
        }