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.Find(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") })); }
// GET: /RSVP/RsvpTwitterFinish public ActionResult RsvpTwitterFinish(int id) { string screenName; int userId; if (TwitterConsumer.TryFinishSignInWithTwitter(out screenName, out userId)) { var dinnerRepository = new DinnerRepository(); Dinner dinner = dinnerRepository.Find(id); // NOTE: The alias we've generated for this user isn't guaranteed to be unique. string alias = "@" + screenName; if (!dinner.IsUserRegistered(alias)) { RSVP rsvp = new RSVP(); rsvp.AttendeeName = alias; dinner.RSVPs.Add(rsvp); dinnerRepository.Save(); } } return(RedirectToAction("Details", "Dinners", new { id = id })); }