Esempio n. 1
0
        protected virtual bool RegisterCore(ControllerContext controllerContext, SubmissionSetting submissionSetting, out string redirectUrl)
        {
            redirectUrl = "";
            var membership = MemberPluginHelper.GetMembership();

            var registerMemberModel = new RegisterMemberModel();

            bool valid = ModelBindHelper.BindModel(registerMemberModel, "", controllerContext, submissionSetting);

            if (valid)
            {
                redirectUrl = registerMemberModel.RedirectUrl;
                if (!string.IsNullOrEmpty(redirectUrl))
                {
                    redirectUrl = MemberPluginHelper.ResolveSiteUrl(controllerContext, redirectUrl);
                }
                try
                {
                    var membershipUser = _manager.Create(membership, registerMemberModel.UserName, registerMemberModel.Email, registerMemberModel.Password, registerMemberModel.IsApproved, registerMemberModel.Culture
                                                         , registerMemberModel.TimeZoneId, registerMemberModel.PasswordQuestion, registerMemberModel.PasswordAnswer, null, registerMemberModel.Profiles, null);

                    if (registerMemberModel.IsApproved == false)
                    {
                        SendActivateMail(controllerContext, Site.Current, membershipUser, registerMemberModel, membershipUser.ActivateCode);
                    }
                }
                catch (DataViolationException e)
                {
                    controllerContext.Controller.ViewData.ModelState.FillDataViolation(e.Violations);
                    valid = false;
                }
                catch (Exception e)
                {
                    controllerContext.Controller.ViewData.ModelState.AddModelError("", e.Message);
                    Kooboo.HealthMonitoring.Log.LogException(e);
                    valid = false;
                }
            }
            return(valid);
        }
Esempio n. 2
0
        protected virtual void SendActivateMail(ControllerContext controllerContext, Site site, MembershipUser memberUser, RegisterMemberModel registerMemberModel, string activateCode)
        {
            var activateUrl = registerMemberModel.ActivateUrl;
            if (string.IsNullOrEmpty(activateUrl))
            {
                throw new ArgumentNullException("ActivateUrl is required.");
            }

            activateUrl = string.Format(MemberPluginHelper.ResolveSiteUrl(controllerContext, activateUrl)
                , memberUser.UserName, activateCode);
            activateUrl = UrlUtility.ToHttpAbsolute(activateUrl);

            var subject = registerMemberModel.EmailSubject;
            var body = string.Format(registerMemberModel.EmailBody, activateUrl);

            site.SendMailToCustomer(registerMemberModel.Email, subject, body, true, null);
        }
Esempio n. 3
0
        protected virtual bool RegisterCore(ControllerContext controllerContext, SubmissionSetting submissionSetting, out string redirectUrl)
        {
            redirectUrl = "";
            var membership = MemberPluginHelper.GetMembership();

            var registerMemberModel = new RegisterMemberModel();

            bool valid = ModelBindHelper.BindModel(registerMemberModel, "", controllerContext, submissionSetting);

            if (valid)
            {
                redirectUrl = registerMemberModel.RedirectUrl;
                if (!string.IsNullOrEmpty(redirectUrl))
                {
                    redirectUrl = MemberPluginHelper.ResolveSiteUrl(controllerContext, redirectUrl);
                }
                try
                {
                    var membershipUser = _manager.Create(membership, registerMemberModel.UserName, registerMemberModel.Email, registerMemberModel.Password, registerMemberModel.IsApproved, registerMemberModel.Culture
                    , registerMemberModel.TimeZoneId, registerMemberModel.PasswordQuestion, registerMemberModel.PasswordAnswer, null, registerMemberModel.Profiles, null);

                    if (registerMemberModel.IsApproved == false)
                    {
                        SendActivateMail(controllerContext, Site.Current, membershipUser, registerMemberModel, membershipUser.ActivateCode);
                    }
                }
                catch (DataViolationException e)
                {
                    controllerContext.Controller.ViewData.ModelState.FillDataViolation(e.Violations);
                    valid = false;
                }
                catch (Exception e)
                {
                    controllerContext.Controller.ViewData.ModelState.AddModelError("", e.Message);
                    Kooboo.HealthMonitoring.Log.LogException(e);
                    valid = false;
                }
            }
            return valid;
        }
Esempio n. 4
0
        protected virtual void SendActivateMail(ControllerContext controllerContext, Site site, MembershipUser memberUser, RegisterMemberModel registerMemberModel, string activateCode)
        {
            var activateUrl = registerMemberModel.ActivateUrl;

            if (string.IsNullOrEmpty(activateUrl))
            {
                throw new ArgumentNullException("ActivateUrl is required.");
            }

            activateUrl = string.Format(MemberPluginHelper.ResolveSiteUrl(controllerContext, activateUrl)
                                        , memberUser.UserName, activateCode);
            activateUrl = UrlUtility.ToHttpAbsolute(activateUrl);

            var subject = registerMemberModel.EmailSubject;
            var body    = string.Format(registerMemberModel.EmailBody, activateUrl);

            site.SendMailToCustomer(registerMemberModel.Email, subject, body, true, null);
        }