Beispiel #1
0
 public UserDeliverable(
     TextReader reader,
     TextWriter writer,
     UmbracoMembershipProviderBase membershipProvider
     ) : base(reader, writer)
 {
     this.membershipProvider = membershipProvider;
 }
Beispiel #2
0
 public UserDeliverable(
     TextReader reader,
     TextWriter writer,
     UmbracoMembershipProviderBase membershipProvider
 ) : base(reader, writer)
 {
     this.membershipProvider = membershipProvider;
 }
Beispiel #3
0
        public ActionResult HandleRegisterGuestForm(RegisterGuestForm registerGuestForm)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.CurrentUmbracoPage());
            }

            // no helper method on this.Members to register a user with a given memberType, so calling provider directly
            UmbracoMembershipProviderBase membersUmbracoMembershipProvider = (UmbracoMembershipProviderBase)Membership.Providers[Constants.Conventions.Member.UmbracoMemberProviderName];

            MembershipCreateStatus membershipCreateStatus;

            MembershipUser membershipUser = membersUmbracoMembershipProvider.CreateUser(
                PartyGuest.Alias,                                                               // member type alias
                registerGuestForm.EmailAddress,                                                 // username
                registerGuestForm.Password,                                                     // password
                registerGuestForm.EmailAddress,                                                 // email
                null,                                                                           // forgotten password question
                null,                                                                           // forgotten password answer
                true,                                                                           // is approved
                null,                                                                           // provider user key
                out membershipCreateStatus);

            if (membershipCreateStatus != MembershipCreateStatus.Success)
            {
                switch (membershipCreateStatus)
                {
                case MembershipCreateStatus.DuplicateEmail:
                case MembershipCreateStatus.DuplicateUserName:

                    this.ModelState.AddModelError("RegisterGuestValidation", "Email already registered");

                    break;
                }

                return(this.CurrentUmbracoPage());
            }

            // cast from MembershipUser rather than use this.Members.GetCurrentMember() helper (which needs a round trip for the login)
            PartyGuest partyGuest = (PartyGuest)membershipUser;

            partyGuest.FacebookRegistration = false;

            // update database with member and party guid (duplicated data, but never changes)
            this.DatabaseContext.Database.Insert(new MemberPartyRow(partyGuest.Id, registerGuestForm.PartyGuid));

            // (duplicate data) store party guid in cms cache
            partyGuest.PartyGuid = registerGuestForm.PartyGuid;

            // add member to DotMailer
            DotMailerService.GuestRegistrationStarted((Contact)partyGuest);

            // send cookie
            FormsAuthentication.SetAuthCookie(partyGuest.Username, true);

            //return this.NavigateToRegisterGuestUrl(registerGuestForm.PartyGuid);
            return(this.Redirect(this.Umbraco.TypedContentSingleAtXPath("//" + RegisterGuest.Alias).Url + "?partyGuid=" + registerGuestForm.PartyGuid.ToString()));
        }
        internal static BackOfficeUserManager InitUserManager(BackOfficeUserStore store, UmbracoMembershipProviderBase membershipProvider, IdentityFactoryOptions<BackOfficeUserManager> options)
        {
            var manager = new UmbracoEasyADUserManager(store);
            
            // Just use the InitUserManager method in Umbraco!
            manager.InitUserManager(manager, membershipProvider, options);

            return manager;
        }
        public ActionResult HandleRegisterHostForm(RegisterHostForm registerHostForm)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.CurrentUmbracoPage());
            }

            // no helper method on this.Members to register a user with a given memberType, so calling provider directly
            UmbracoMembershipProviderBase membersUmbracoMembershipProvider = (UmbracoMembershipProviderBase)Membership.Providers[Constants.Conventions.Member.UmbracoMemberProviderName];

            MembershipCreateStatus membershipCreateStatus;

            MembershipUser membershipUser = membersUmbracoMembershipProvider.CreateUser(
                PartyHost.Alias,                                                                // member type alias
                registerHostForm.EmailAddress,                                                  // username
                registerHostForm.Password,                                                      // password
                registerHostForm.EmailAddress,                                                  // email
                null,                                                                           // forgotten password question
                null,                                                                           // forgotten password answer
                true,                                                                           // is approved
                null,                                                                           // provider user key
                out membershipCreateStatus);

            if (membershipCreateStatus != MembershipCreateStatus.Success)
            {
                switch (membershipCreateStatus)
                {
                case MembershipCreateStatus.DuplicateEmail:
                case MembershipCreateStatus.DuplicateUserName:

                    this.ModelState.AddModelError("RegisterHostValidation", "Email already registered");

                    break;
                }

                return(this.CurrentUmbracoPage());
            }

            // cast from MembershipUser rather than use this.Members.GetCurrentMember() helper (which needs a round trip for the login)
            PartyHost partyHost = (PartyHost)membershipUser;

            partyHost.FacebookRegistration = false;

            partyHost.MarketingSource = registerHostForm.MarketingSource;

            Guid partyGuid = Guid.NewGuid();

            this.DatabaseContext.Database.Insert(new PartyRow(partyGuid));

            // update database with member and party guid (duplicated data, but never changes)
            this.DatabaseContext.Database.Insert(new MemberPartyRow(partyHost.Id, partyGuid));

            // (duplicate data) store party guid in cms cache
            partyHost.PartyGuid = partyGuid;

            // set the default custom url to be the party guid
            partyHost.PartyUrlIdentifier = partyGuid.ToString();

            // set default party date
            partyHost.PartyDateTime = PartyHost.DefaultPartyDate;

            // add member to DotMailer
            DotMailerService.HostRegistrationStarted((Contact)partyHost);

            // send cookie
            FormsAuthentication.SetAuthCookie(partyHost.Username, true);

            // cause redirect, so that the login takes effect
            return(this.RedirectToCurrentUmbracoPage());
        }
        public FormResponse RegisterGuest([FromUri] Guid partyGuid, [FromBody] FacebookCredentials facebookCredentials)
        {
            FormResponse formResponse = new FormResponse();

            FacebookDetails facebookDetails = this.GetFacebookDetails(facebookCredentials);

            // no helper method on this.Members to register a user with a given memberType, so calling provider directly
            UmbracoMembershipProviderBase membersUmbracoMembershipProvider = (UmbracoMembershipProviderBase)Membership.Providers[Constants.Conventions.Member.UmbracoMemberProviderName];

            MembershipCreateStatus membershipCreateStatus;

            MembershipUser membershipUser = membersUmbracoMembershipProvider.CreateUser(
                PartyGuest.Alias,                                                              // member type alias
                facebookDetails.EmailAddress,                                                  // username
                this.GetPassword(facebookDetails),                                             // password
                facebookDetails.EmailAddress,                                                  // email
                null,                                                                          // forgotten password question
                null,                                                                          // forgotten password answer
                true,                                                                          // is approved
                null,                                                                          // provider user key
                out membershipCreateStatus);

            if (membershipCreateStatus != MembershipCreateStatus.Success)
            {
                switch (membershipCreateStatus)
                {
                case MembershipCreateStatus.DuplicateEmail:
                case MembershipCreateStatus.DuplicateUserName:

                    this.ModelState.AddModelError("RegisterGuestValidation", "Email already registered");

                    formResponse.Errors = this.ModelState.GetErrors();

                    break;
                }

                return(formResponse);
            }

            // cast from MembershipUser rather than use this.Members.GetCurrentMember() helper (which needs a round trip for the login)
            PartyGuest partyGuest = (PartyGuest)membershipUser;

            partyGuest.FacebookRegistration = true;

            partyGuest.FirstName = facebookDetails.FirstName;
            partyGuest.LastName  = facebookDetails.LastName;

            // update database with member and party guid (duplicated data, but never changes)
            this.DatabaseContext.Database.Insert(new MemberPartyRow(partyGuest.Id, partyGuid));

            // (duplicate data) store party guid in cms cache
            partyGuest.PartyGuid = partyGuid;

            // add member to DotMailer
            DotMailerService.GuestRegistrationStarted((Contact)partyGuest);

            // send cookie
            FormsAuthentication.SetAuthCookie(partyGuest.Username, true);

            formResponse.Success = true;

            formResponse.Message = this.Umbraco.TypedContentSingleAtXPath("//" + Wonderland.Logic.Models.Content.RegisterGuest.Alias).Url;

            return(formResponse);
        }
Beispiel #7
0
        internal static BackOfficeUserManager InitUserManager(BackOfficeUserStore store, UmbracoMembershipProviderBase membershipProvider, IdentityFactoryOptions <BackOfficeUserManager> options)
        {
            var manager = new UmbracoEasyADUserManager(store);

            // Just use the InitUserManager method in Umbraco!
            manager.InitUserManager(manager, membershipProvider, options);

            return(manager);
        }