public virtual async Task <ActionResult> RegisterAsync(MemberAddViewModel userModel, CancellationToken cancellationToken = default(CancellationToken)) { if (ModelState.IsValid) { var mailAddress = new MailAddress(userModel.Email); if (!await _groupInviteService.InviteExistsForMailAddressAsync(mailAddress, cancellationToken)) { ModelState.AddModelError(nameof(userModel.Email), "This user has not been invited onto the platform. Please check the email address provided."); return(View(userModel)); } var settings = SettingsService.GetSettings(); if (settings.SuspendRegistration != true && settings.DisableStandardRegistration != true) { // First see if there is a spam question and if so, the answer matches if (!string.IsNullOrWhiteSpace(settings.SpamQuestion)) { // There is a spam question, if answer is wrong return with error if (userModel.SpamAnswer == null || userModel.SpamAnswer.Trim() != settings.SpamAnswer) { // POTENTIAL SPAMMER! ModelState.AddModelError(string.Empty, "There was an error with your answer. Please try again"); return(View()); } } // Get the user model var user = userModel.ToMembershipUser(); var pipeline = await MembershipService.CreateUserAsync(user, LoginType.Standard, cancellationToken); if (!pipeline.Successful) { ModelState.AddModelError(nameof(userModel.Email), pipeline.ProcessLog.FirstOrDefault()); return(View()); } // Do the register logic return(MemberRegisterLogic(pipeline)); } return(RedirectToAction("Index", "Home")); } return(View()); }