コード例 #1
0
        public async Task <ActionResult> UpdateProfileClaims(UpdateProfileClaimsViewModel model)
        {
            var userId = User.Identity.GetUserId();
            await ProfileClient.AddOrUpdateClaims(userId, new List <Claim>
            {
                new Claim(Common.Consts.DefaultClaimNamespace + "name", model.Name),
                new Claim(Common.Consts.DefaultClaimNamespace + "address", model.Address)
            });

            await RefreshClaims(userId);

            return(RedirectToAction("Index"));
        }
コード例 #2
0
        private async Task InitViewBag()
        {
            ViewBag.ConnectUrls    = GetFederationManagementUrls(ViewBag.Claims, ManagementDisconnectedAccountType, "connect");
            ViewBag.DisconnectUrls = GetFederationManagementUrls(ViewBag.Claims, ManagementConnectedAccountType, "disconnect");
            try
            {
                var claims = await ProfileClient.GetClaims(User.Identity.GetUserId());

                var profile = new UpdateProfileClaimsViewModel
                {
                    Name    = claims.FirstOrDefault(x => x.Type == Common.Consts.DefaultClaimNamespace + "name")?.Value ?? "",
                    Address = claims.FirstOrDefault(x => x.Type == Common.Consts.DefaultClaimNamespace + "address")?.Value ?? ""
                };
                ViewBag.Profile = profile;
            }
            catch (ApiException)
            {
                ViewBag.Profile = new UpdateProfileClaimsViewModel {
                    Address = "", Name = ""
                };
            }
        }