Example #1
0
    protected void btnForgetPassword_Click(object sender, EventArgs e)
    {
        if (ValidateCaptcha())
        {
            MembershipController member = new MembershipController();
            if (txtEmail.Text != "")
            {
                UserInfo user = member.GerUserByEmail(txtEmail.Text, GetPortalID);
                if (!string.IsNullOrEmpty(user.UserName))
                {
                    if (user.Email.ToLower().Equals(txtEmail.Text.ToLower()))
                    {
                        ForgotPasswordInfo objInfo = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_FORGOT_USERNAME_PASSWORD_MATCH, GetPortalID);

                        List <ForgotPasswordInfo> objList = UserManagementController.GetMessageTemplateListByMessageTemplateTypeID(SystemSetting.PASSWORD_CHANGE_REQUEST_EMAIL, GetPortalID);
                        foreach (ForgotPasswordInfo objPwd in objList)
                        {
                            DataTable      dtTokenValues           = UserManagementController.GetPasswordRecoveryTokenValue(user.UserName, GetPortalID);
                            CommonFunction comm                    = new CommonFunction();
                            string         replaceMessageSubject   = MessageToken.ReplaceAllMessageToken(objPwd.Subject, dtTokenValues);
                            string         replacedMessageTemplate = MessageToken.ReplaceAllMessageToken(objPwd.Body, dtTokenValues);
                            try
                            {
                                divForgotPasswordFrom.Visible = false;
                                divSuccessReq.Visible         = true;
                                divSuccessReq.InnerHtml       = "<h3>Password recover request is success and recover link is send to " + user.Email + " <h3>";
                                MailHelper.SendMailNoAttachment(objPwd.MailFrom, txtEmail.Text, replaceMessageSubject, replacedMessageTemplate, string.Empty, string.Empty);
                            }
                            catch (Exception)
                            {
                                FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("PasswordRecovery", "SecureConnectionFPError"));
                            }
                        }
                    }
                    else
                    {
                        InitializeCaptcha();
                        FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("PasswordRecovery", "UsernameOrEmailAddressDoesnotMatched"));
                    }
                }
                else
                {
                    InitializeCaptcha();
                    FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserManagement", "UserDoesnotExist"));
                }
            }
            else
            {
                InitializeCaptcha();
                FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("PasswordRecovery", "PleaseEnterAllTheRequiredFields"));
            }
        }
        else
        {
            CaptchaValue.Text = string.Empty;
        }
    }
Example #2
0
        public void HandlePostRegistration(int UserRegistrationType)
        {
            switch (UserRegistrationType)
            {
            case 0:
                ForgotPasswordInfo template = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.USER_RESISTER_SUCESSFUL_INFORMATION_NONE, GetPortalID);
                if (template != null)
                {
                    USER_RESISTER_SUCESSFUL_INFORMATION.Text = template.Body;
                }
                break;

            case 1:
                template = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.USER_RESISTER_SUCESSFUL_INFORMATION_PRIVATE, GetPortalID);
                if (template != null)
                {
                    USER_RESISTER_SUCESSFUL_INFORMATION.Text = template.Body;
                }
                this.divRegistration.Visible = true;
                this.divRegConfirm.Visible   = true;
                this.divRegister.Visible     = false;
                break;

            case 3:
                template = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.USER_RESISTER_SUCESSFUL_INFORMATION_VERIFIED, GetPortalID);
                if (template != null)
                {
                    USER_RESISTER_SUCESSFUL_INFORMATION.Text = template.Body;
                }

                List <ForgotPasswordInfo> objFpwd = UserManagementController.GetMessageTemplateListByMessageTemplateTypeID(SystemSetting.ACCOUNT_ACTIVATION_EMAIL, GetPortalID);
                foreach (ForgotPasswordInfo messageTemplate in objFpwd)
                {
                    CommonFunction comm = new CommonFunction();
                    DataTable      dtActivationTokenValues = UserManagementController.GetActivationTokenValue(UserName.Text, GetPortalID);
                    string         replaceMessageSubject   = MessageToken.ReplaceAllMessageToken(messageTemplate.Subject, dtActivationTokenValues);
                    string         replacedMessageTemplate = MessageToken.ReplaceAllMessageToken(messageTemplate.Body, UserName.Text, GetPortalID);
                    //  string replacedMessageTemplate = MessageToken.ReplaceAllMessageToken(messageTemplate.Body, dtActivationTokenValues);
                    MailHelper.SendMailNoAttachment(messageTemplate.MailFrom, Email.Text, replaceMessageSubject, replacedMessageTemplate, string.Empty, string.Empty);
                }
                // CheckDivVisibility(false, true);
                this.divRegistration.Visible = true;
                this.divRegConfirm.Visible   = true;
                this.divRegister.Visible     = false;
                break;

            case 2:
                template = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.USER_RESISTER_SUCESSFUL_INFORMATION_PUBLIC, GetPortalID);
                if (template != null)
                {
                    USER_RESISTER_SUCESSFUL_INFORMATION.Text = template.Body;
                }
                LogInPublicModeRegistration();
                break;
            }
        }
 protected void wzdPasswordRecover_NextButtonClick(object sender, WizardNavigationEventArgs e)
 {
     try
     {
         if (txtPassword.Text != null && txtRetypePassword.Text != "" && txtRetypePassword.Text == txtPassword.Text)
         {
             if (txtPassword.Text.Length < 4)
             {
                 ShowMessage("", GetSageMessage("PasswordRecovery", "PasswordLength"), "", SageMessageType.Alert);
                 e.Cancel = true;
             }
             else
             {
                 if (hdnRecoveryCode.Value != "")
                 {
                     sageframeuser = UserManagementController.GetUsernameByActivationOrRecoveryCode(hdnRecoveryCode.Value, GetPortalID);
                     if (sageframeuser.CodeForUsername != null)
                     {
                         UserInfo userOld = m.GetUserDetails(GetPortalID, sageframeuser.CodeForUsername);
                         string   Password, PasswordSalt;
                         PasswordHelper.EnforcePasswordSecurity(m.PasswordFormat, txtPassword.Text, out Password, out PasswordSalt);
                         UserInfo user = new UserInfo(userOld.UserID, Password, PasswordSalt, m.PasswordFormat);
                         m.ChangePassword(user);
                         List <ForgotPasswordInfo> messageTemplates = UserManagementController.GetMessageTemplateListByMessageTemplateTypeID(SystemSetting.PASSWORD_RECOVERED_SUCCESSFUL_EMAIL, GetPortalID);
                         foreach (ForgotPasswordInfo messageTemplate in messageTemplates)
                         {
                             DataTable dtTokenValues           = UserManagementController.GetPasswordRecoverySuccessfulTokenValue(userOld.UserName, GetPortalID);
                             string    replacedMessageSubject  = MessageToken.ReplaceAllMessageToken(messageTemplate.Subject, dtTokenValues);
                             string    replacedMessageTemplate = MessageToken.ReplaceAllMessageToken(messageTemplate.Body, dtTokenValues);
                             try
                             {
                                 MailHelper.SendMailNoAttachment(messageTemplate.MailFrom, userOld.Email, replacedMessageSubject, replacedMessageTemplate, string.Empty, string.Empty);
                             }
                             catch (Exception)
                             {
                                 ShowMessage("", GetSageMessage("PasswordRecovery", "SecureConnectionFPRError"), "", SageMessageType.Alert);
                                 e.Cancel = true;
                                 divRecoverpwd.Visible = false;
                             }
                         }
                         UserManagementController.DeactivateRecoveryCode(userOld.UserName, GetPortalID);
                         ForgotPasswordInfo template = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_RECOVERED_SUCESSFUL_INFORMATION, GetPortalID);
                         if (template != null)
                         {
                             ((Literal)WizardStep2.FindControl("litPasswordChangedSuccessful")).Text = template.Body;
                         }
                     }
                     else
                     {
                         e.Cancel = true;
                         ShowMessage("", GetSageMessage("PasswordRecovery", "UnknownErrorPleaseTryAgaing"), "", SageMessageType.Alert);
                     }
                 }
                 else
                 {
                     e.Cancel = true;
                     ShowMessage("", GetSageMessage("PasswordRecovery", "UnknownError"), "", SageMessageType.Alert);
                 }
             }
         }
         else
         {
             ShowMessage("", GetSageMessage("PasswordRecovery", "PleaseEnterAllRequiredFields"), "", SageMessageType.Alert);
             e.Cancel = true;
         }
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
        protected void wzdForgetPassword_NextButtonClick(object sender, WizardNavigationEventArgs e)
        {
            try
            {
                MembershipController member = new MembershipController();
                if (txtEmail.Text != "" && txtUsername.Text != "")
                {
                    UserInfo user = member.GetUserDetails(GetPortalID, txtUsername.Text);
                    if (user.UserExists)
                    {
                        if (user.IsApproved == true)
                        {
                            if (user.Email.ToLower().Equals(txtEmail.Text.ToLower()))
                            {
                                ForgetPasswordInfo objInfo = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_FORGET_USERNAME_PASSWORD_MATCH, GetPortalID);

                                if (objInfo != null)
                                {
                                    ((Literal)WizardStep2.FindControl("litInfoEmailFinish")).Text = objInfo.Body;
                                }

                                List <ForgetPasswordInfo> objList = UserManagementController.GetMessageTemplateListByMessageTemplateTypeID(SystemSetting.PASSWORD_CHANGE_REQUEST_EMAIL, GetPortalID);

                                foreach (ForgetPasswordInfo objPwd in objList)
                                {
                                    DataTable dtTokenValues = UserManagementController.GetPasswordRecoveryTokenValue(txtUsername.Text, GetPortalID);

                                    CommonFunction comm = new CommonFunction();
                                    string         replaceMessageSubject   = MessageToken.ReplaceAllMessageToken(objPwd.Subject, dtTokenValues);
                                    string         replacedMessageTemplate = MessageToken.ReplaceAllMessageToken(objPwd.Body, dtTokenValues);
                                    try
                                    {
                                        MailHelper.SendMailNoAttachment(objPwd.MailFrom, txtEmail.Text, replaceMessageSubject, replacedMessageTemplate, string.Empty, string.Empty);
                                    }
                                    catch (Exception)
                                    {
                                        divForgotPwd.Visible = false;
                                        ShowMessage("", GetSageMessage("PasswordRecovery", "SecureConnectionFPError"), "", SageMessageType.Alert);
                                        e.Cancel = true;
                                    }
                                }
                            }
                            else
                            {
                                ShowMessage("", GetSageMessage("PasswordRecovery", "UsernameOrEmailAddressDoesnotMatched"), "", SageMessageType.Alert);
                                e.Cancel = true;
                            }
                        }
                        else
                        {
                            ShowMessage("", GetSageMessage("PasswordRecovery", "UsernameNotActivated"), "", SageMessageType.Alert);
                            e.Cancel = true;
                        }
                    }
                    else
                    {
                        ShowMessage("", GetSageMessage("UserManagement", "UserDoesNotExist"), "", SageMessageType.Alert);
                        e.Cancel = true;
                    }
                }
                else
                {
                    e.Cancel = true;
                    ShowMessage("", GetSageMessage("PasswordRecovery", "PleaseEnterAllTheRequiredFields"), "", SageMessageType.Alert);
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    SageFrameConfig pb             = new SageFrameConfig();
                    string          ActivationCode = string.Empty;
                    if (Request.QueryString["ActivationCode"] != null)
                    {
                        ActivationCode = Request.QueryString["ActivationCode"].ToString();
                        try
                        {
                            ActivationCode = EncryptionMD5.Decrypt(ActivationCode);
                        }
                        catch
                        {
                            ShowMessage("", GetSageMessage("UserRegistration", "InvalidActivationCode"), "", SageMessageType.Alert);
                            return;
                        }
                        ForgotPasswordInfo sageframeuser = new ForgotPasswordInfo();
                        sageframeuser = UserManagementController.GetUsernameByActivationOrRecoveryCode(ActivationCode, GetPortalID);
                        if (sageframeuser.CodeForUsername != null)
                        {
                            if (!sageframeuser.IsAlreadyUsed)
                            {
                                string UserName = _member.ActivateUser(ActivationCode, GetPortalID);
                                if (!String.IsNullOrEmpty(UserName))
                                {
                                    UserInfo user = _member.GetUserDetails(GetPortalID, UserName);
                                    if (user.UserExists)
                                    {
                                        List <ForgotPasswordInfo> messageTemplates = UserManagementController.GetMessageTemplateListByMessageTemplateTypeID(SystemSetting.ACTIVATION_SUCCESSFUL_EMAIL, GetPortalID);

                                        foreach (ForgotPasswordInfo messageTemplate in messageTemplates)
                                        {
                                            DataTable dtActivationSuccessfulTokenValues = UserManagementController.GetActivationSuccessfulTokenValue(user.UserName, GetPortalID);
                                            string    replaceMessageSubject             = MessageToken.ReplaceAllMessageToken(messageTemplate.Subject, dtActivationSuccessfulTokenValues);
                                            string    replacedMessageTemplate           = MessageToken.ReplaceAllMessageToken(messageTemplate.Body, dtActivationSuccessfulTokenValues);
                                            try
                                            {
                                                MailHelper.SendMailNoAttachment(messageTemplate.MailFrom, user.Email, replaceMessageSubject, replacedMessageTemplate, string.Empty, string.Empty);
                                            }
                                            catch (Exception)
                                            {
                                                ShowMessage("", GetSageMessage("UserRegistration", "SecureConnectionUAEmailError"), "", SageMessageType.Alert);
                                                return;
                                            }
                                        }
                                        ForgotPasswordInfo template = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.ACTIVATION_SUCCESSFUL_INFORMATION, GetPortalID);
                                        if (template != null)
                                        {
                                            ACTIVATION_INFORMATION.Text = template.Body;
                                        }
                                        ;
                                        LogInPublicModeRegistration(user);
                                    }
                                    else
                                    {
                                        ShowMessage("", GetSageMessage("UserManagement", "UserDoesNotExist"), "", SageMessageType.Alert);
                                    }
                                }
                                else
                                {
                                    ForgotPasswordInfo template = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.ACTIVATION_FAIL_INFORMATION, GetPortalID);
                                    if (template != null)
                                    {
                                        ACTIVATION_INFORMATION.Text = template.Body;
                                    }
                                    ;
                                }
                            }
                            else
                            {
                                ShowMessage("", GetSageMessage("UserRegistration", "ActivationCodeAlreadyUsed"), "", SageMessageType.Alert);
                            }
                        }
                        else
                        {
                            ShowMessage("", GetSageMessage("UserManagement", "UserDoesNotExist"), "", SageMessageType.Alert);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ProcessException(ex);
                }
            }
        }