public JsonResult CheckFacebookAccount(string facebookID) { using (new UnitOfWorkScope()) { var service = new UserProfileService(); var result = service.IsFacebookAccountUnique(facebookID); return Json(result, JsonRequestBehavior.AllowGet); } }
public ActionResult RegisterUser(FacebookRegisterModel model, string returnUrl) { // TODO: Rebuild functionality using CoffeeScript implementation and new C# API if (ModelState.IsValid) { var userProfile = Mapper.Map<FacebookRegisterModel, UserProfile>(model); using (new UnitOfWorkScope()) { var userProfileService = new UserProfileService(userProfileRepository); var organization = OrganizationRepository.GetDefaultOrganization(readOnly: false); if (!userProfileService.IsFacebookAccountUnique(userProfile.FacebookID)) { TempData["ModelErrors"] = new List<string> { "This FacebookID is already in use by another user account. Please sign in with a different Facebook account." }; return RedirectToAction("Register", new { returnUrl = returnUrl }); } if (organization.UserProfiles == null) { organization.UserProfiles = new List<UserProfile>(); } userProfile.Active = true; userProfile.IsActivated = false; var service = new GrassrootsMembershipService(); userProfile.ActivationHash = service.GetUserAuthorizationHash(); userProfile.LastActivationAttempt = DateTime.Now; organization.UserProfiles.Add(userProfile); OrganizationRepository.Save(); accountMailer.Authorize(new AuthorizeModel { Email = userProfile.Email, FirstName = userProfile.FirstName, LastName = userProfile.LastName, SenderEmail = organization.ContactEmail, SenderName = organization.Name, Url = Url.ToPublicUrl(Url.Action("Activate", "Account", new { hash = userProfile.ActivationHash })) }).SendAsync(); return RedirectToAction("AwaitingActivation", "Account"); } } return RedirectToAction("Register"); }
public void SetUp() { userProfileRepository = new FakeUserProfileRepository(); service = new UserProfileService(userProfileRepository); }