Beispiel #1
0
        protected ContentResult RegisterLogic(UserRegistration userRegistrationParams)
        {
            Response result;
            // 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);
                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();
                }
                var json = registeredServicesData.ToString();
                result = _utilsServices.GetResponse(ResponseType.Success, message, json);
            } catch (Exception ex) {
                result = _utilsServices.GetResponse(ResponseType.None, ex.Message);
            }
            return(_utilsServices.ConvertToJsonResult(result));
        }
Beispiel #2
0
        public Response RegisterLogic(UserRegistration userRegistrationParams)
        {
            Response result;
            // 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(result);
            }
            try {
                _usersExtensionsServices.Register(userRegistrationParams);

                var registeredServicesData = _utilsServices.GetUserIdentityProviders(_identityProviders);
                var json = registeredServicesData.ToString();
                result = _utilsServices.GetResponse(ResponseType.Success, data: json);
            } catch (Exception ex) {
                result = _utilsServices.GetResponse(ResponseType.None, ex.Message);
            }
            return(result);
        }