Exemple #1
0
        public RegisterModel Register(MembershipHelper Members)
        {
            RegisterModel Register = Members.CreateRegistrationModel("member");

            Register.Name            = this.Name;
            Register.Email           = this.Email;
            Register.UsernameIsEmail = true;
            Register.Password        = this.Password;

            return(Register);
        }
Exemple #2
0
 private RegisterModel(bool doLookup)
 {
     MemberTypeAlias             = Constants.Conventions.MemberTypes.DefaultAlias;
     RedirectOnSucces            = false;
     UsernameIsEmail             = true;
     MemberProperties            = new List <UmbracoProperty>();
     LoginOnSuccess              = true;
     CreatePersistentLoginCookie = true;
     if (doLookup && UmbracoContext.Current != null)
     {
         var helper = new MembershipHelper(UmbracoContext.Current);
         var model  = helper.CreateRegistrationModel(MemberTypeAlias);
         MemberProperties = model.MemberProperties;
     }
 }
        private RegistrationResult RegisterNewmUmbracoMember(RegistrationFormModel registrationFormModel)
        {
            var result = new RegistrationResult();

            var registrationModel = _membershipHelper.CreateRegistrationModel();

            registrationModel.Email    = registrationFormModel.Email;
            registrationModel.Username = registrationFormModel.Email;
            registrationModel.Password = registrationFormModel.Password;

            MembershipCreateStatus mbershipCreateStatus = new MembershipCreateStatus();

            _membershipHelper.RegisterMember(registrationModel, out mbershipCreateStatus, false);

            if (mbershipCreateStatus == MembershipCreateStatus.Success)
            {
                _memberService.AssignRole(registrationModel.Email, "Site member");
                result.Success = true;
            }

            switch (mbershipCreateStatus)
            {
            case MembershipCreateStatus.DuplicateEmail:
                result.Errors.Add("Account with given email already exists");
                break;

            case MembershipCreateStatus.DuplicateUserName:
                result.Errors.Add("Account with given email already exists");
                break;

            case MembershipCreateStatus.InvalidEmail:
                result.Errors.Add("Invalid email address");
                break;

            case MembershipCreateStatus.InvalidPassword:
                result.Errors.Add("Invalid password");
                break;

            case MembershipCreateStatus.InvalidUserName:
                result.Errors.Add("Invalid email address");
                break;
            }


            return(result);
        }