public ActionResult CheckEmail(string email) { Regex regex = new Regex(@"^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$"); if (regex.IsMatch(email)) { if (registeredUserRepository.GetByMail(email) == null) { return(Json(new { Exist = false, RegExError = false, Email = email })); } return(Json(new { Exist = true, RegExError = false, Email = email })); } return(Json(new { Exist = true, RegExError = true, Email = email })); }
public ViewResult ChangeEmail(UserFull userModification) { if (ModelState.IsValid) { if (registeredUserRepository.GetByMail(userModification.Email) == null) { MembershipUser mu = Membership.GetUser(); RegisteredUser ru = (RegisteredUser)registeredUserRepository.GetByMembershipId(Convert.ToInt32(mu.ProviderUserKey)); ru.NewMail = userModification.Email; ru.RegistrationCode = Guid.NewGuid().ToString(); registeredUserRepository.SaveOrUpdate(ru); registerMemberService.SendValidationCode(ru, Url.Action("Validate", "EmailConfirmation")); Response.Redirect(Url.RouteUrl(new { controller = "EmailConfirmation", action = "Index", userid = mu.ProviderUserKey })); } else { userModification.Alert = userModification.Email + " is in use"; } } userModification.Tab = 1; userModification = GetAccountData(userModification); return(View("Index", userModification)); }
public ViewResult ChangeEmail(UserFull userModification) { UserEmail userEmail = new UserEmail(userModification); var errors = userEmail.Validate(); if (errors == null) { if (registeredUserRepository.GetByMail(userModification.Email) == null) { MembershipUser mu = Membership.GetUser(); PublicUser ru = (PublicUser)registeredUserRepository.GetByMembershipId(Convert.ToInt32(mu.ProviderUserKey)); mu.Email = userModification.Email; ru.EmailAddress = userModification.Email; registeredUserRepository.SaveOrUpdate(ru); userModification.Alert = "User email updated successfully"; } else { errors = new ErrorSummary(); errors.RegisterErrorMessage("Email", "That email already exist in our database"); } } if (errors != null) { Session["Errors"] = errors.ErrorMessages; } userModification.Tab = 1; userModification = GetAccountData(userModification); return(View("Index", userModification)); }
public ActionResult CheckNewEmail(string email) { return(EmailCheck(registeredUserRepository.GetByMail(email), email)); }