Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Extension = SageFrameSettingKeys.PageExtension;
            IncludeJs("UserRegistration", false, "/js/jquery.pstrength-min.1.2.js");
            IncludeJs("UserRegistrationValidation", "/js/jquery.validate.js");
            try
            {
                if (GetPortalID > 1)
                {
                    defpage = ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension);
                }
                else
                {
                    defpage = ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension);
                }
                int UserRegistrationType = pagebase.GetSettingIntByKey(SageFrameSettingKeys.PortalUserRegistration);

                if (UserRegistrationType == 0)
                {
                    Response.Redirect(defpage);
                }
                IncludeCss("UserRegistration", "/Administrator/Templates/Default/css/login.css");
                ForgotPasswordInfo template = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.USER_REGISTRATION_HELP, GetPortalID);
                if (template != null)
                {
                    headerTemplate = "<div>" + template.Body + "</div>";
                }
                if (!IsPostBack)
                {
                    if (_member.EnableCaptcha)
                    {
                        InitializeCaptcha();
                        GenerateCaptchaImage();
                    }
                    else
                    {
                        HideCaptcha();
                    }
                    SetValidatorErrorMessage();
                    CheckDivVisibility(true, false);
                    this.divRegister.Visible     = true;
                    this.divRegistration.Visible = false;
                    this.divRegConfirm.Visible   = false;
                }
                if (GetPortalID > 1)
                {
                    LoginPath = ResolveUrl("~/portal/" + GetPortalSEOName + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + Extension);
                }
                else
                {
                    LoginPath = ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + Extension);
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
Exemplo n.º 2
0
        private void HideSignUp()
        {
            int UserRegistrationType = pagebase.GetSettingIntByKey(SageFrameSettingKeys.PortalUserRegistration);

            RegisterURL = UserRegistrationType > 0 ? true : false;
            if (!RegisterURL)
            {
                //this.divSignUp.Visible = false;
            }
        }
        private void CheckUserRegistrationType()
        {
            int userRegistrationType = pagebase.GetSettingIntByKey(SageFrameSettingKeys.PortalUserRegistration);

            switch (userRegistrationType)
            {
            case 0:
                Response.Redirect(LoginPath, false);
                break;

            case 1:
                break;

            case 2:
                break;

            case 3:
                break;
            }
        }
    //private bool ValidateCaptcha()
    //{
    //    if (!(cvCaptchaValue.ValueToCompare == CaptchaValue.Text))
    //    {
    //        ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserRegistration", "EnterTheCorrectCapchaCode"), "", SageMessageType.Error);
    //        return false;
    //    }

    //    return true;
    //}

    private void RegisterUser()
    {
        try
        {
            if (string.IsNullOrEmpty(UserName.Text) || string.IsNullOrEmpty(FirstName.Text) || string.IsNullOrEmpty(LastName.Text) || string.IsNullOrEmpty(Email.Text))
            {
                ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserRegistration", "PleaseEnterAllRequiredFields"), "", SageMessageType.Alert);
                CheckIfSucccess = 0;
            }
            else
            {
                int UserRegistrationType = pagebase.GetSettingIntByKey(SageFrameSettingKeys.PortalUserRegistration);

                bool isUserActive = UserRegistrationType == 2 ? true : false;

                UserInfo objUser = new UserInfo();
                objUser.ApplicationName = Membership.ApplicationName;
                objUser.FirstName       = FirstName.Text;
                objUser.UserName        = UserName.Text;
                objUser.LastName        = LastName.Text;
                string Pwd, PasswordSalt;
                PasswordHelper.EnforcePasswordSecurity(_member.PasswordFormat, Password.Text, out Pwd, out PasswordSalt);
                objUser.Password         = Pwd;
                objUser.PasswordSalt     = PasswordSalt;
                objUser.Email            = Email.Text;
                objUser.SecurityQuestion = Question.Text;
                objUser.SecurityAnswer   = Answer.Text;
                objUser.IsApproved       = true;
                objUser.CurrentTimeUtc   = DateTime.Now;
                objUser.CreatedDate      = DateTime.Now;
                objUser.UniqueEmail      = 0;
                objUser.PasswordFormat   = _member.PasswordFormat;
                objUser.PortalID         = GetPortalID;
                objUser.AddedOn          = DateTime.Now;
                objUser.AddedBy          = GetUsername;
                objUser.UserID           = Guid.NewGuid();
                objUser.RoleNames        = SystemSetting.REGISTER_USER_ROLENAME;
                objUser.StoreID          = GetStoreID;
                objUser.CustomerID       = 0;

                UserCreationStatus status = new UserCreationStatus();
                CheckRegistrationType(UserRegistrationType, ref objUser);

                MembershipDataProvider.CreatePortalUser(objUser, out status, UserCreationMode.REGISTER);
                if (status == UserCreationStatus.DUPLICATE_USER)
                {
                    ShowMessage(SageMessageTitle.Notification.ToString(), UserName.Text.Trim() + " " + GetSageMessage("UserManagement", "NameAlreadyExists"), "", SageMessageType.Alert);
                    CheckIfSucccess = 0;
                }
                else if (status == UserCreationStatus.DUPLICATE_EMAIL)
                {
                    ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "EmailAddressAlreadyIsInUse"), "", SageMessageType.Alert);
                    CheckIfSucccess = 0;
                }
                else if (status == UserCreationStatus.SUCCESS)
                {
                    if (chkIsSubscribeNewsLetter.Checked)
                    {
                        int?newID = 0;
                        ManageNewsLetterSubscription(Email.Text, ref newID);
                    }
                    ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "UserCreatedSuccessfully"), "", SageMessageType.Success);
                    CheckIfSucccess = 1;
                    ClearFormValue();
                }
            }
        }

        catch (Exception ex)
        {
            ProcessException(ex);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        SageFrameConfig pb = new SageFrameConfig();

        IsUseFriendlyUrls = pb.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls);
        //if (!IsPostBack)
        //{
        profileText = GetSageMessage("LoginStatus", "MyProfile");
        Literal lnkProfileUrl = (Literal)LoginView1.TemplateControl.FindControl("lnkProfileUrl");

        RegisterURL = pb.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage) + ".aspx";
        if (pb.GetSettingsByKey(SageFrameSettingKeys.PortalShowProfileLink) == "1")
        {
            if (IsUseFriendlyUrls)
            {
                if (GetPortalID > 1)
                {
                    profileURL = "<a  href='" + ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pb.GetSettingsByKey(SageFrameSettingKeys.PortalUserProfilePage) + ".aspx") + "'>" + profileText + "</a>";
                }
                else
                {
                    profileURL = "<a  href='" + ResolveUrl("~/" + pb.GetSettingsByKey(SageFrameSettingKeys.PortalUserProfilePage) + ".aspx") + "'>" + profileText + "</a>";
                }
            }
            else
            {
                profileURL = "<a  href='" + ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pb.GetSettingsByKey(SageFrameSettingKeys.PortalUserProfilePage)) + "'>" + profileText + "</a>";
            }
        }
        else
        {
            profileURL = "";
        }
        if (IsUseFriendlyUrls)
        {
            if (GetPortalID > 1)
            {
                RegisterURL = ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pb.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage) + ".aspx");
            }
            else
            {
                RegisterURL = ResolveUrl("~/" + pb.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage) + ".aspx");
            }
        }
        else
        {
            RegisterURL = ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pb.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage));
        }
        if (HttpContext.Current.User != null)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated == true)
            {
                Label lblProfileURL = LoginView1.FindControl("lblProfileURL") as Label;
                if (lblProfileURL != null)
                {
                    if (profileURL != "")
                    {
                        lblProfileURL.Text    = "<li>" + profileURL + "</li>";
                        lblProfileURL.Visible = true;
                    }
                    else
                    {
                        lblProfileURL.Visible = false;
                    }
                }
                else
                {
                    Response.Redirect(pb.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx");
                }
            }
        }
        int UserRegistrationType = pb.GetSettingIntByKey(SageFrameSettingKeys.PortalUserRegistration);

        if (UserRegistrationType > 0)
        {
            RegisterURL = "<span class='cssClassRegister'><a href='" + RegisterURL + "'>" + GetSageMessage("LoginStatus", "Register") + "</a></span>";
        }
        else
        {
            RegisterURL = "";
        }
        //}
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        IncludeLanguageJS();
        Extension = SageFrameSettingKeys.PageExtension;
        SageFrameConfig pb = new SageFrameConfig();

        IsUseFriendlyUrls = pb.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls);
        profileText       = GetSageMessage("LoginStatus", "MyProfile");
        Literal lnkProfileUrl = (Literal)LoginView1.TemplateControl.FindControl("lnkProfileUrl");

        RegisterURL = pb.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage) + Extension;
        if (pb.GetSettingsByKey(SageFrameSettingKeys.PortalShowProfileLink) == "1")
        {
            string profilepage = pb.GetSettingsByKey(SageFrameSettingKeys.PortalUserProfilePage);
            profilepage = profilepage.ToLower().Equals("user-profile")
                              ? string.Format("/sf/{0}", profilepage)
                              : string.Format("/{0}", profilepage);
            if (GetPortalID > 1)
            {
                profileURL = "<a  href='" + ResolveUrl("~/portal/" + GetPortalSEOName + profilepage + Extension) + "'>" +
                             profileText + "</a>";
            }
            else
            {
                profileURL = "<a  href='" + ResolveUrl("~" + profilepage + Extension) + "'>" + profileText + "</a>";
            }
        }
        else
        {
            profileURL = string.Empty;
        }
        string userName = GetUsername;

        if (userName.ToLower() == "anonymoususer")
        {
            divAnonymousTemplate.Visible = true;
            divLoggedInTemplate.Visible  = false;
            userName = "******";
        }
        else
        {
            divAnonymousTemplate.Visible = false;
            divLoggedInTemplate.Visible  = true;
        }
        //  Label lblWelcomeMsg = LoginView1.FindControl("lblWelcomeMsg") as Label;
        // lblWelcomeMsg.Text = "<h2><span onload='GetMyLocale(this)'>Welcome " + userName + "!</span></h2>";

        lblWelcomeMsg.Text = lblWelcomeMsg.Text + " " + userName;
        if (IsUseFriendlyUrls)
        {
            if (GetPortalID > 1)
            {
                RegisterURL = ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pb.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage) + Extension);
            }
            else
            {
                RegisterURL = ResolveUrl("~/" + pb.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage) + Extension);
            }
        }
        else
        {
            RegisterURL = ResolveUrl("~/Default" + Extension + "?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pb.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage));
        }

        int UserRegistrationType = pb.GetSettingIntByKey(SageFrameSettingKeys.PortalUserRegistration);

        if (UserRegistrationType > 0)
        {
            RegisterURL = "<span><a href='" + RegisterURL + "'>" + GetSageMessage("LoginStatus", "Register") + "</a></span>";
        }
        else
        {
            RegisterURL = "";
        }
    }