protected ContentResult RegisterLogic(UserRegistration userRegistrationParams) { Response result; ResponseType responseType; // ensure users can request lost password var registrationSettings = OrchardServices.WorkContext.CurrentSite.As <RegistrationSettingsPart>(); if (!registrationSettings.UsersCanRegister) { result = UtilsServices.GetResponse(ResponseType.None, T("Users cannot register due to site settings.").Text); return(UtilsServices.ConvertToJsonResult(result)); } try { _usersExtensionsServices.Register(userRegistrationParams); List <string> roles = new List <string>(); var message = ""; var registeredServicesData = UtilsServices.GetUserIdentityProviders(_identityProviders); var json = registeredServicesData.ToString(); responseType = ResponseType.Success; if (OrchardServices.WorkContext.CurrentUser == null && registrationSettings.UsersMustValidateEmail) { message = T("Thank you for registering. We sent you an e-mail with instructions to enable your account.").ToString(); responseType = ResponseType.ToConfirmEmail; } result = UtilsServices.GetResponse(responseType, message, json); } catch (Exception ex) { result = UtilsServices.GetResponse(ResponseType.None, ex.Message); } return(UtilsServices.ConvertToJsonResult(result)); }