public override bool ValidateUser(string username, string password) { var service = new GrassrootsMembershipService(); return service.ValidateUser(username, password, MaxInvalidPasswordAttempts); }
public override bool UnlockUser(string userName) { var service = new GrassrootsMembershipService(); return service.UnlockUser(userName); }
public override void UpdateUser(MembershipUser user) { var service = new GrassrootsMembershipService(); service.UpdateUser(user); }
public override MembershipUser GetUser(string username, bool userIsOnline) { var service = new GrassrootsMembershipService(); return service.GetUser(username); }
public override string ResetPassword(string username, string answer) { var service = new GrassrootsMembershipService(); return service.ResetPassword(username, EnablePasswordReset); }
public ActionResult SendAuthorizationNote(AuthorizeModel model) { using (userProfileRepository) { var userProfile = userProfileRepository.FindUserProfileByEmail(model.Email).FirstOrDefault(); var organization = OrganizationRepository.GetDefaultOrganization(readOnly: true); if (userProfile == null) { TempData["UserFeedback"] = "We couldn't find that email address in our system. Are you sure that was the right one?"; return RedirectToAction("AwaitingActivation", "Account"); } var service = new GrassrootsMembershipService(); userProfile.ActivationHash = service.GetUserAuthorizationHash(); userProfile.LastActivationAttempt = DateTime.Now; userProfileRepository.Save(); accountMailer.Authorize(MapAuthorizeModel(userProfile, organization)).SendAsync(); } TempData["UserFeedback"] = "We just sent you an email. Check your email account and follow the instructions inside."; return RedirectToAction("AwaitingActivation", "Account"); }
public override int GetNumberOfUsersOnline() { var service = new GrassrootsMembershipService(); return service.GetNumberOfUsersOnline(); }
/// <summary> /// Sets Active bool to null on User object. For tax purposes, we may not want to delete user accounts outright. /// </summary> /// <param name="username">Username to deactivate</param> /// <param name="deleteAllRelatedData"></param> /// <returns>Boolean indicating success</returns> public override bool DeleteUser(string username, bool deleteAllRelatedData) { var service = new GrassrootsMembershipService(); return service.DeleteUser(username); }
public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) { var service = new GrassrootsMembershipService(); return service.FindUsersByName(usernameToMatch, out totalRecords); }
public override bool ChangePassword(string username, string oldPassword, string newPassword) { var service = new GrassrootsMembershipService(); return service.ChangePassword(username, oldPassword, newPassword); }
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { var service = new GrassrootsMembershipService(); return service.CreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, providerUserKey, out status, RequiresUniqueEmail); }
/// <summary> /// Check if activation hash is valid. /// * If yes, set user profile IsActivated to true and redirect to login /// * If no, redirect to AwaitingActivation /// </summary> /// <param name="hash">ashed string to compare</param> /// <returns>Redirect based on result</returns> public RedirectToRouteResult Activate(string hash, string redirect = "") { if (hash == null) { return RedirectToAction("AwaitingActivation", "Account", new { returnUrl = redirect }); } using (userProfileRepository) { var userProfile = userProfileRepository.GetUserProfileByActivationHash(hash); var organization = OrganizationRepository.GetDefaultOrganization(readOnly: true); var service = new GrassrootsMembershipService(); if (userProfile == null) { TempData["UserFeedback"] = "Are you sure you have an account here?"; return RedirectToAction("Register", new { returnUrl = redirect }); } if (service.IsActivationHashValid(userProfile)) { userProfile.IsActivated = true; // Check for existing donations var previousDonations = from d in campaignDonorRepository.FindAllDonations() where d.Email == userProfile.Email && d.UserProfile == null select d; foreach (var donation in previousDonations) { donation.UserProfileID = userProfile.UserProfileID; } campaignDonorRepository.Save(); userProfileRepository.Save(); TempData["UserFeedback"] = "Sweet! Your account is activated. Please log in."; accountMailer.Welcome(MapWelcomeModel(userProfile, organization)).SendAsync(); return RedirectToAction("LogOn", "Account", new { returnUrl = redirect }); } } TempData["UserFeedback"] = "Looks like your activation request may have expired. Complete the form below to try again."; return RedirectToAction("AwaitingActivation", "Account"); }
public ActionResult UpdateForgottenPassword(string hash, UpdatePasswordModel model) { if (ModelState.IsValid) { using (new UnitOfWorkScope()) { var userProfile = userProfileRepository.GetUserProfileByActivationHash(hash); var service = new GrassrootsMembershipService(); if (userProfile == null) { TempData["UserFeedback"] = "The email you are looking for could not be found in our system."; return RedirectToAction("ForgotPassword"); } if (service.UpdatePassword(userProfile, model.ActivationPin, model.Password)) { var mailModel = Mapper.Map<UserProfile, RegisterModel>(userProfile); accountMailer.PasswordChange(mailModel).SendAsync(); TempData["UserFeedback"] = "Sweet! Your password has been changed. You can now log in with your new password."; return RedirectToAction("LogOn"); } } } var activationHash = hash; return RedirectToAction("UpdatePassword", new { hash = activationHash }); }
public ActionResult SendPasswordReset(ForgotPasswordModel model) { if (ModelState.IsValid) { using (userProfileRepository) { var userProfile = userProfileRepository.FindUserProfileByEmail(model.Email).FirstOrDefault(); if (userProfile != null) { var service = new GrassrootsMembershipService(); userProfile.ActivationHash = service.GetUserAuthorizationHash(); userProfile.ActivationPin = service.GenerateRandomPin(); userProfile.LastActivationAttempt = DateTime.Now; userProfileRepository.Save(); accountMailer.PasswordReset(MapPasswordReset(userProfile)).SendAsync(); return RedirectToAction("UpdatePassword", new { hash = userProfile.ActivationHash }); } } TempData["UserFeedback"] = "The email you are looking for could not be found in our system."; } TempData["ForgotPasswordModel"] = model; return RedirectToAction("ForgotPassword"); }
public ActionResult RegisterUser(FacebookRegisterModel model, string returnUrl) { if (ModelState.IsValid) { var userProfile = Mapper.Map<FacebookRegisterModel, UserProfile>(model); using (new UnitOfWorkScope()) { var organization = OrganizationRepository.GetDefaultOrganization(readOnly: false); 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 override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) { var service = new GrassrootsMembershipService(); return service.GetAllUsers(pageIndex, pageSize, out totalRecords); }
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 ActionResult RegisterUser(RegisterModel model, string returnUrl = "") { if (ModelState.IsValid) { MembershipCreateStatus status; UserProfile userProfile; Organization organization; using (new UnitOfWorkScope()) using (var transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew)) { // This should ensure best compatiblity through a variety of SQL database environments // (e.g. - SQL Server, MySQL, SQL Azure). userProfile = Mapper.Map<RegisterModel, UserProfile>(model); organization = OrganizationRepository.GetDefaultOrganization(readOnly: false); 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(); status = MembershipService.CreateUser(model.Email, model.Password, model.Email); transactionScope.Complete(); } if (status == MembershipCreateStatus.Success) { accountMailer.Authorize(MapAuthorizeModel(userProfile, organization, returnUrl)).SendAsync(); return RedirectToAction("AwaitingActivation", "Account"); } } var url = returnUrl; TempData["RegisterModel"] = model; TempData["ModelErrors"] = FindModelErrors(); return RedirectToAction("Register", "Account", new { returnUrl = url }); }