public bool ChangePassword(AspxCommonInfo aspxCommonObj, string newPassword, string retypePassword)
        {
            MembershipController m = new MembershipController();

            try
            {
                if (newPassword != "" && retypePassword != "" && newPassword == retypePassword && aspxCommonObj.UserName != "")
                {
                    UserInfo sageUser = m.GetUserDetails(aspxCommonObj.PortalID, aspxCommonObj.UserName);
                    // Guid userID = (Guid)member.ProviderUserKey;
                    string password, passwordSalt;
                    PasswordHelper.EnforcePasswordSecurity(m.PasswordFormat, newPassword, out password, out passwordSalt);
                    UserInfo user = new UserInfo(sageUser.UserID, password, passwordSalt, m.PasswordFormat);
                    m.ChangePassword(user);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public bool ChangePassword(AspxCommonInfo aspxCommonObj, string newPassword, string retypePassword)
 {
     MembershipController m = new MembershipController();
     try
     {
         if (newPassword != "" && retypePassword != "" && newPassword == retypePassword && aspxCommonObj.UserName != "")
         {
             UserInfo sageUser = m.GetUserDetails(aspxCommonObj.PortalID, aspxCommonObj.UserName);
             // Guid userID = (Guid)member.ProviderUserKey;
             string password, passwordSalt;
             PasswordHelper.EnforcePasswordSecurity(m.PasswordFormat, newPassword, out password, out passwordSalt);
             UserInfo user = new UserInfo(sageUser.UserID, password, passwordSalt, m.PasswordFormat);
             m.ChangePassword(user);
             return true;
         }
         else
         {
             return false;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
    protected void btnManagePasswordSave_Click(object sender, EventArgs e)
    {
        MembershipController m        = new MembershipController();
        List <UserInfo>      lstUsers = m.SearchUsers("", "", GetPortalID, GetUsername).UserList;
        string UserID = "";

        foreach (UserInfo objInfo in lstUsers)
        {
            if (objInfo.UserName == GetUsername)
            {
                UserID = objInfo.UserID.ToString();
            }
        }

        try
        {
            if (txtNewPassword.Text != "" && txtRetypeNewPassword.Text != "" && txtNewPassword.Text == txtRetypeNewPassword.Text && GetUsername != "")
            {
                if (txtNewPassword.Text.Length >= 4 && txtNewPassword.Text.Length <= 20)
                {
                    MembershipUser member = Membership.GetUser(GetUsername);
                    string         Password, PasswordSalt;
                    PasswordHelper.EnforcePasswordSecurity(m.PasswordFormat, txtNewPassword.Text, out Password, out PasswordSalt);
                    UserInfo user = new UserInfo(new Guid(UserID), Password, PasswordSalt, m.PasswordFormat);
                    m.ChangePassword(user);
                    ShowMessage("", GetSageMessage("UserManagement", "UserPasswordChangedSuccessfully"), "", SageMessageType.Success);
                }
                else
                {
                    ShowMessage("", GetSageMessage("UserManagement", "PasswordLength"), "", SageMessageType.Alert);
                }
            }
            else
            {
                ShowMessage("", GetSageMessage("UserManagement", "Retype Password doesn't match"), "", SageMessageType.Alert);
            }
            LoadUserDetails();
            divUserInfo.Visible                = true;
            tblEditProfile.Visible             = false;
            tblViewProfile.Visible             = true;
            imgProfileEdit.Visible             = false;
            imgProfileView.Visible             = true;
            btnDeleteProfilePic.Visible        = false;
            divEditprofile.Visible             = true;
            sfUserProfile.Visible              = false;
            Session[SessionKeys.Profile_Image] = null;
        }
        catch (Exception ex)
        {
            ProcessException(ex);
        }
    }
Ejemplo n.º 4
0
 protected void btnManagePasswordSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtNewPassword.Text != "" && txtRetypeNewPassword.Text != "" && txtNewPassword.Text == txtRetypeNewPassword.Text && hdnEditUsername.Value != "")
         {
             MembershipUser member = Membership.GetUser(hdnEditUsername.Value);
             string         Password, PasswordSalt;
             PasswordHelper.EnforcePasswordSecurity(m.PasswordFormat, txtNewPassword.Text, out Password, out PasswordSalt);
             UserInfo user = new UserInfo(new Guid(hdnEditUserID.Value), Password, PasswordSalt, m.PasswordFormat);
             m.ChangePassword(user);
             ShowMessage(SageMessageTitle.Information.ToString(), GetSageMessage("UserManagement", "UserPasswordChangedSuccessfully"), "", SageMessageType.Success);
         }
         else
         {
             ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserManagement", "PleaseEnterTheRequiredField"), "", SageMessageType.Alert);
         }
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
        protected void btnResetPassword_Click(object sender, EventArgs e)
        {
            string DecPassword = AESEncrytDecry.DecryptStringAES(HDPassword.Value);

            if (DecPassword == "keyError")
            {
                FailureText.Text = string.Format("<span class='sfError'>{0}</span>", GetSageMessage("UserLogin", "UsernameandPasswordcombinationdoesntmatched"));//"Username and Password combination doesn't matched!";
            }
            UserInfo userOld = m.GetUserDetails(GetPortalID, hdnUserName.Value);
            string   Password, PasswordSalt;

            PasswordHelper.EnforcePasswordSecurity(m.PasswordFormat, DecPassword, out Password, out PasswordSalt);
            UserInfo user = new UserInfo(userOld.UserID, Password, PasswordSalt, m.PasswordFormat);

            m.ChangePassword(user);
            FailureText.Text = string.Format("<p class='sfSuccess'>{0}</p>", "Password Changed Successfully.");
            divRecoverPasswordFrom.Visible = false;
            divSuccessReq.Visible          = true;
            divSuccessReq.InnerHtml        = "<a href='/login'>Go to login</a>";
            UserManagementController.DeactivateRecoveryCode(userOld.UserName, GetPortalID);
            rfvConfirmPass.Visible = false;
            rfvPassword.Visible    = false;
            cmpPassword.Visible    = false;
        }
 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 btnManagePasswordSave_Click(object sender, EventArgs e)
    {
        MembershipController m = new MembershipController();
        List<UserInfo> lstUsers = m.SearchUsers("", "", GetPortalID, GetUsername).UserList;
        string UserID = "";
        foreach (UserInfo objInfo in lstUsers)
        {
            if (objInfo.UserName == GetUsername)
            {
                UserID = objInfo.UserID.ToString();
            }
        }

        try
        {
            if (txtNewPassword.Text != "" && txtRetypeNewPassword.Text != "" && txtNewPassword.Text == txtRetypeNewPassword.Text && GetUsername != "")
            {
                if (txtNewPassword.Text.Length >= 4)
                {
                    MembershipUser member = Membership.GetUser(GetUsername);
                    string Password, PasswordSalt;
                    PasswordHelper.EnforcePasswordSecurity(m.PasswordFormat, txtNewPassword.Text, out Password, out PasswordSalt);
                    UserInfo user = new UserInfo(new Guid(UserID), Password, PasswordSalt, m.PasswordFormat);
                    m.ChangePassword(user);
                    ShowMessage("", GetSageMessage("UserManagement", "UserPasswordChangedSuccessfully"), "", SageMessageType.Success);
                }
                else
                {
                    ShowMessage("", GetSageMessage("UserManagement", "PasswordLength"), "", SageMessageType.Alert);
                }
            }
            else
            {
                ShowMessage("", GetSageMessage("UserManagement", "Retype Password doesn't match"), "", SageMessageType.Alert);
            }
            LoadUserDetails();
            divUserInfo.Visible = true;
            tblEditProfile.Visible = false;
            tblViewProfile.Visible = true;
            imgProfileEdit.Visible = false;
            imgProfileView.Visible = true;
            btnDeleteProfilePic.Visible = false;
            divEditprofile.Visible = true;
            sfUserProfile.Visible = false;
            Session[SessionKeys.Profile_Image] = null;
        }
        catch (Exception ex)
        {
            ProcessException(ex);
        }
    }
Ejemplo n.º 8
0
    public bool ChangePassword(int portalID, int storeID, string userName, string newPassword, string retypePassword)
    {
        MembershipController m = new MembershipController();
        try
        {
            if (newPassword != "" && retypePassword != "" && newPassword == retypePassword && userName != "")
            {
                UserInfo sageUser = m.GetUserDetails(portalID, userName);

                MembershipUser member = Membership.GetUser(userName);
               // Guid userID = (Guid)member.ProviderUserKey;
                string Password, PasswordSalt;
                PasswordHelper.EnforcePasswordSecurity(m.PasswordFormat, newPassword, out Password, out PasswordSalt);
                UserInfo user = new UserInfo(sageUser.UserID, Password, PasswordSalt, m.PasswordFormat);
                m.ChangePassword(user);
                return true;
            }
            else
            {
                return false;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Ejemplo n.º 9
0
        protected void wzdPasswordRecover_NextButtonClick(object sender, WizardNavigationEventArgs e)
        {
            try
            {
                MessageTemplateDataContext dbMessageTemplate = new MessageTemplateDataContext(SystemSetting.SageFrameConnectionString);
                if (txtPassword.Text != null && txtRetypePassword.Text != "" && txtRetypePassword.Text == txtPassword.Text)
                {
                    if (txtPassword.Text.Length < 4)
                    {
                        ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("PasswordRecovery", "PasswordLength"), "", SageMessageType.Alert);
                        e.Cancel = true;
                    }
                    else
                    {
                        if (hdnRecoveryCode.Value != "")
                        {
                            UserManagementDataContext dbUser = new UserManagementDataContext(SystemSetting.SageFrameConnectionString);
                            var sageframeuser = dbUser.sp_GetUsernameByActivationOrRecoveryCode(hdnRecoveryCode.Value, GetPortalID).SingleOrDefault();
                            if (sageframeuser != null)
                            {
                                MembershipController m = new MembershipController();
                                UserInfo sageUser = m.GetUserDetails(GetPortalID, sageframeuser.CodeForUsername);
                                //MembershipUser user = Membership.GetUser(sageframeuser.CodeForUsername);
                                string Password, PasswordSalt;
                                PasswordHelper.EnforcePasswordSecurity(m.PasswordFormat, txtPassword.Text, out Password, out PasswordSalt);
                                UserInfo user1 = new UserInfo(sageUser.UserID, Password, PasswordSalt, m.PasswordFormat);
                                m.ChangePassword(user1);
                                //string oldPassword = user.ResetPassword();

                                //user.ChangePassword(oldPassword, txtPassword.Text);

                                var template = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_RECOVERED_SUCESSFUL_INFORMATION, GetPortalID).SingleOrDefault();
                                if (template != null)
                                {
                                    ((Literal)WizardStep2.FindControl("litPasswordChangedSuccessful")).Text = template.Body;
                                }
                                var messageTemplates = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_RECOVERED_SUCCESSFUL_EMAIL, GetPortalID);
                                foreach (var messageTemplate in messageTemplates)
                                {
                                    MessageTokenDataContext messageTokenDB = new MessageTokenDataContext(SystemSetting.SageFrameConnectionString);
                                    var messageTokenValues = messageTokenDB.sp_GetPasswordRecoverySuccessfulTokenValue(sageUser.UserName, GetPortalID);
                                    CommonFunction comm = new CommonFunction();
                                    DataTable dtTokenValues = comm.LINQToDataTable(messageTokenValues);
                                    string replacedMessageSubject = MessageToken.ReplaceAllMessageToken(messageTemplate.Subject, dtTokenValues);
                                    string replacedMessageTemplate = MessageToken.ReplaceAllMessageToken(messageTemplate.Body, dtTokenValues);
                                    MailHelper.SendMailNoAttachment(messageTemplate.MailFrom, sageUser.Email, replacedMessageSubject, replacedMessageTemplate, string.Empty, string.Empty);
                                }
                            }
                            else
                            {
                                var template = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_RECOVERED_SUCESSFUL_INFORMATION, GetPortalID).SingleOrDefault();
                                if (template != null)
                                {
                                    ((Literal)WizardStep2.FindControl("litPasswordChangedSuccessful")).Text = template.Body;
                                }
                                e.Cancel = true;
                                ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("PasswordRecovery", "UnknownErrorPleaseTryAgaing"), "", SageMessageType.Alert);
                            }
                        }
                        else
                        {
                            var template = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_RECOVERED_SUCESSFUL_INFORMATION, GetPortalID).SingleOrDefault();
                            if (template != null)
                            {
                                ((Literal)WizardStep2.FindControl("litPasswordChangedSuccessful")).Text = template.Body;
                            }
                            e.Cancel = true;
                            ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("PasswordRecovery", "UnknownError"), "", SageMessageType.Alert);
                        }
                    }
                }
                else
                {
                    ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("PasswordRecovery", "PleaseEnterAllRequiredFields"), "", SageMessageType.Alert);
                    e.Cancel = true;
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
Ejemplo n.º 10
0
        protected void wzdPasswordRecover_NextButtonClick(object sender, WizardNavigationEventArgs e)
        {
            try
            {
                MessageTemplateDataContext dbMessageTemplate = new MessageTemplateDataContext(SystemSetting.SageFrameConnectionString);
                if (txtPassword.Text != null && txtRetypePassword.Text != "" && txtRetypePassword.Text == txtPassword.Text)
                {
                    if (txtPassword.Text.Length < 4)
                    {
                        ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("PasswordRecovery", "PasswordLength"), "", SageMessageType.Alert);
                        e.Cancel = true;
                    }
                    else
                    {
                        if (hdnRecoveryCode.Value != "")
                        {
                            UserManagementDataContext dbUser = new UserManagementDataContext(SystemSetting.SageFrameConnectionString);
                            var sageframeuser = dbUser.sp_GetUsernameByActivationOrRecoveryCode(hdnRecoveryCode.Value, GetPortalID).SingleOrDefault();
                            if (sageframeuser.CodeForUsername != null)
                            {
                                MembershipController m        = new MembershipController();
                                UserInfo             sageUser = m.GetUserDetails(GetPortalID, sageframeuser.CodeForUsername);
                                //MembershipUser user = Membership.GetUser(sageframeuser.CodeForUsername);
                                string Password, PasswordSalt;
                                PasswordHelper.EnforcePasswordSecurity(m.PasswordFormat, txtPassword.Text, out Password, out PasswordSalt);
                                UserInfo user1 = new UserInfo(sageUser.UserID, Password, PasswordSalt, m.PasswordFormat);
                                m.ChangePassword(user1);
                                //string oldPassword = user.ResetPassword();

                                //user.ChangePassword(oldPassword, txtPassword.Text);


                                var messageTemplates = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_RECOVERED_SUCCESSFUL_EMAIL, GetPortalID);
                                foreach (var messageTemplate in messageTemplates)
                                {
                                    MessageTokenDataContext messageTokenDB = new MessageTokenDataContext(SystemSetting.SageFrameConnectionString);
                                    var            messageTokenValues      = messageTokenDB.sp_GetPasswordRecoverySuccessfulTokenValue(sageUser.UserName, GetPortalID);
                                    CommonFunction comm                    = new CommonFunction();
                                    DataTable      dtTokenValues           = comm.LINQToDataTable(messageTokenValues);
                                    string         replacedMessageSubject  = MessageToken.ReplaceAllMessageToken(messageTemplate.Subject, dtTokenValues);
                                    string         replacedMessageTemplate = MessageToken.ReplaceAllMessageToken(messageTemplate.Body, dtTokenValues);
                                    try
                                    {
                                        MailHelper.SendMailNoAttachment(messageTemplate.MailFrom, sageUser.Email, replacedMessageSubject, replacedMessageTemplate, string.Empty, string.Empty);
                                    }
                                    catch (Exception)
                                    {
                                        ShowMessage("", GetSageMessage("PasswordRecovery", "SecureConnectionFPRError"), "", SageMessageType.Alert);
                                        e.Cancel = true;
                                        divRecoverpwd.Visible = false;
                                    }
                                }
                                UserManagementController.DeactivateRecoveryCode(sageUser.UserName, GetPortalID);
                                var template = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_RECOVERED_SUCESSFUL_INFORMATION, GetPortalID).SingleOrDefault();
                                if (template != null)
                                {
                                    ((Literal)WizardStep2.FindControl("litPasswordChangedSuccessful")).Text = template.Body;
                                }
                            }
                            else
                            {
                                //var template = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_RECOVERED_SUCESSFUL_INFORMATION, GetPortalID).SingleOrDefault();
                                //if (template != null)
                                //{
                                //    ((Literal)WizardStep2.FindControl("litPasswordChangedSuccessful")).Text = template.Body;
                                //}
                                e.Cancel = true;
                                ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("PasswordRecovery", "UnknownErrorPleaseTryAgaing"), "", SageMessageType.Alert);
                            }
                        }
                        else
                        {
                            //var template = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_RECOVERED_SUCESSFUL_INFORMATION, GetPortalID).SingleOrDefault();
                            //if (template != null)
                            //{
                            //    ((Literal)WizardStep2.FindControl("litPasswordChangedSuccessful")).Text = template.Body;
                            //}
                            e.Cancel = true;
                            ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("PasswordRecovery", "UnknownError"), "", SageMessageType.Alert);
                        }
                    }
                }
                else
                {
                    ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("PasswordRecovery", "PleaseEnterAllRequiredFields"), "", SageMessageType.Alert);
                    e.Cancel = true;
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }