public ActionResult Authenticate() { Authentication.OpenIdUser openIdUser; string message; if (OpenIdHelper.ValidateResponse(out openIdUser, out message)) { // check to see if we need to create an account in the system var user = _openIdUserRepository.GetNullableById(openIdUser.ClaimedIdentifier); // does not exist create a new one if (user == null) { user = new OpenIdUser() { UserId = openIdUser.ClaimedIdentifier }; openIdUser.Email = openIdUser.Email; _openIdUserRepository.EnsurePersistent(user); // redirect to the edit page return this.RedirectToAction(a => a.OpenIdAccount()); } // user exists but email was never filled out else if (string.IsNullOrEmpty(user.Email)) { Message = "Please fill in at least an email address."; return this.RedirectToAction(a => a.OpenIdAccount()); } // redirect to the return url if (!string.IsNullOrEmpty(ReturnUrl)) { return Redirect(ReturnUrl); } return this.RedirectToAction<HomeController>(a => a.Index()); } // failure, give the message to the user Message = message; return this.RedirectToAction<AccountController>(a => a.LogOn(ReturnUrl, true)); }
public ActionResult OpenIdAccount(OpenIdUser openIDUser) { var destOpenIdUser = _openIdUserRepository.GetNullableById(CurrentUser.Identity.Name); if (destOpenIdUser == null) { return this.RedirectToAction<HomeController>(a => a.Index()); } destOpenIdUser = Copiers.CopyOpenIdUser(openIDUser, destOpenIdUser); MvcValidationAdapter.TransferValidationMessagesTo(ModelState, destOpenIdUser.ValidationResults()); if (ModelState.IsValid) { _openIdUserRepository.EnsurePersistent(destOpenIdUser); Message = NotificationMessages.STR_ObjectSaved.Replace(NotificationMessages.ObjectType, "User information"); } return View(destOpenIdUser); }