Пример #1
0
        public ActionResult RsvpFinish()
        {
            IAuthenticationResponse response = relyingParty.GetResponse();

            if (response == null)
            {
                return(RedirectToAction("Index"));
            }

            if (response.Status == AuthenticationStatus.Authenticated)
            {
                var    dinnerRepository = new DinnerRepository();
                int    id     = int.Parse(response.GetUntrustedCallbackArgument("DinnerId"));
                Dinner dinner = dinnerRepository.GetDinner(id);

                // The alias we're getting here is NOT a secure identifier, but a friendly one,
                // which is all we need for this scenario.
                string alias = response.FriendlyIdentifierForDisplay;
                var    sreg  = response.GetExtension <ClaimsResponse>();
                if (sreg != null && sreg.MailAddress != null)
                {
                    alias = sreg.MailAddress.User;
                }

                // NOTE: The alias we've generated for this user isn't guaranteed to be unique.
                // Need to trim to 30 characters because that's the max for Attendee names.
                if (!dinner.IsUserRegistered(alias))
                {
                    RSVP rsvp = new RSVP();
                    rsvp.AttendeeName   = alias;
                    rsvp.AttendeeNameId = response.ClaimedIdentifier;

                    dinner.RSVPs.Add(rsvp);
                    dinnerRepository.Save();
                }
            }

            return(RedirectToAction("Details", "Dinners", new { id = response.GetUntrustedCallbackArgument("DinnerId") }));
        }
		/// <summary>
		/// Processes the response.
		/// </summary>
		/// <param name="response">The response.</param>
		protected virtual void ProcessResponse(IAuthenticationResponse response) {
			if (response == null) {
				return;
			}
			string persistentString = response.GetUntrustedCallbackArgument(UsePersistentCookieCallbackKey);
			if (persistentString != null) {
				this.UsePersistentCookie = (LogOnPersistence)Enum.Parse(typeof(LogOnPersistence), persistentString);
			}

			switch (response.Status) {
				case AuthenticationStatus.Authenticated:
					this.OnLoggedIn(response);
					break;
				case AuthenticationStatus.Canceled:
					this.OnCanceled(response);
					break;
				case AuthenticationStatus.Failed:
					this.OnFailed(response);
					break;
				case AuthenticationStatus.SetupRequired:
				case AuthenticationStatus.ExtensionsOnly:
				default:
					// The NotApplicable (extension-only assertion) is NOT one that we support
					// in this control because that scenario is primarily interesting to RPs
					// that are asking a specific OP, and it is not user-initiated as this textbox
					// is designed for.
					throw new InvalidOperationException(MessagingStrings.UnexpectedMessageReceivedOfMany);
			}
		}