示例#1
0
        public new ActionResult Profile(ProfileViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return View(model);
            }

            var claimsIdentity = (IClaimsIdentity)User.Identity;

            var emailClaim = claimsIdentity.Claims.SingleOrDefault(c => c.ClaimType.Equals(ClaimTypes.Email, StringComparison.OrdinalIgnoreCase));

            var email = string.Empty;

            if (emailClaim == null)
            {
                throw new InvalidOperationException("The email address could not be retrieved from the claims identity object.");
            }
            else
            {
                email = emailClaim.Value;
            }

            var user = this.userService.RetrieveUserByEMail(email);

            if (user == null)
            {
                throw new InvalidOperationException(string.Format("No user could be found with the claims email address '{0}'.", email));
            }

            user.Name = model.Name;

            this.userService.UpdateUser(user);

            this.ExecuteLogOff();
            return this.RedirectToAction("Index", "Home");
        }
示例#2
0
        public ActionResult Invitation(string ticketNumber)
        {
            if (this.Request.UrlReferrer == null)
            {
                // Request is not coming from ACS
                // Force the call to the ClaimsAuthenticationManager
                FederatedAuthentication.ServiceConfiguration.ClaimsAuthenticationManager.Authenticate(
                    this.Request.Url.AbsolutePath,
                    (IClaimsPrincipal)Thread.CurrentPrincipal);
            }

            Guid invitationId;

            try
            {
                var urlSplitted = this.Request.Url.AbsoluteUri.Split(new char[1] { '/' });
                invitationId = new Guid(urlSplitted[urlSplitted.Length - 1]);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("The invitation Id could not be retrieved from the url.", ex);
            }

            var user = this.userService.RetrieveUserByInvitationId(invitationId);

            if (user == null)
            {
                throw new InvalidOperationException("The user associated with the invitation could not be found.");
            }

            var name = User.Identity.Name;

            var model = new ProfileViewModel()
            {
                Id = user.UserId,
                Name = user.Name,
                OriginalName = user.Name
            };

            return this.View("Invitation", model);
        }
示例#3
0
        public new ActionResult Profile()
        {
            var name = User.Identity.Name;
            var user = this.userService.SearchUsers(name).FirstOrDefault();

            var model = new ProfileViewModel()
            {
                Id = user.UserId,
                Name = user.Name,
                OriginalName = user.Name
            };

            return this.View(model);
        }