protected void Page_Load(object sender, EventArgs e) { MessageTemplateDataContext dbMessageTemplate = new MessageTemplateDataContext(SystemSetting.SageFrameConnectionString); var template = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_RECOVERED_HELP, GetPortalID).SingleOrDefault(); if (template != null) { helpTemplate = template.Body; } if (!IsPostBack) { string RecoveringCode = string.Empty; if (Request.QueryString["RecoveringCode"] != null) { RecoveringCode = Request.QueryString["RecoveringCode"].ToString(); try { RecoveringCode = EncryptionMD5.Decrypt(RecoveringCode); hdnRecoveryCode.Value = RecoveringCode; AddImageUrls(); UserManagementDataContext dbUser = new UserManagementDataContext(SystemSetting.SageFrameConnectionString); var sageframeuser = dbUser.sp_GetUsernameByActivationOrRecoveryCode(hdnRecoveryCode.Value, GetPortalID).SingleOrDefault(); if (sageframeuser.CodeForUsername != null) { if ((bool)(sageframeuser.IsAlreadyUsed)) { ShowMessage("", GetSageMessage("PasswordRecovery", "RecoveryCodeAlreadyActivated"), "", SageMessageType.Alert); divRecoverpwd.Visible = false; } else { divRecoverpwd.Visible = true; } } else { divRecoverpwd.Visible = false; ShowMessage("", GetSageMessage("UserManagement", "UserDoesNotExist"), "", SageMessageType.Alert); } } catch { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("PasswordRecovery", "InvalidRecoveringCode"), "", SageMessageType.Alert); divRecoverpwd.Visible = false; } } else { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("PasswordRecovery", "RecoveringCodeIsNotAvailable"), "", SageMessageType.Error); divRecoverpwd.Visible = false; } SetValidatorErrorMessage(); } }
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); } }
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); } }
protected void Page_Load(object sender, EventArgs e) { SageFrameConfig pagebase = new SageFrameConfig(); IsUseFriendlyUrls = pagebase.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls); hypGotoLogin.Text = GetSageMessage("UserRegistration", "GoToLogin"); if (IsUseFriendlyUrls) { if (GetPortalID > 1) { hypGotoLogin.NavigateUrl = ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + ".aspx"); } else { hypGotoLogin.NavigateUrl = ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + ".aspx"); } } else { hypGotoLogin.NavigateUrl = ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage)); } if (!IsPostBack) { try { MessageTemplateDataContext dbMessageTemplate = new MessageTemplateDataContext(SystemSetting.SageFrameConnectionString); string ActivationCode = string.Empty; if (Request.QueryString["ActivationCode"] != null) { ActivationCode = Request.QueryString["ActivationCode"].ToString(); try { ActivationCode = EncryptionMD5.Decrypt(ActivationCode); } catch { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserRegistration", "InvalidActivationCode"), "", SageMessageType.Alert); return; } UserManagementDataContext dbUser = new UserManagementDataContext(SystemSetting.SageFrameConnectionString); var sageframeuser = dbUser.sp_GetUsernameByActivationOrRecoveryCode(ActivationCode, GetPortalID).SingleOrDefault(); if (sageframeuser.CodeForUsername != null) { if (!(bool)(sageframeuser.IsAlreadyUsed)) { string UserName = _member.ActivateUser(ActivationCode, GetPortalID, GetStoreID); if (!String.IsNullOrEmpty(UserName)) { UserInfo user = _member.GetUserDetails(GetPortalID, UserName); if (user.UserExists) { var messageTemplates = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.ACTIVATION_SUCCESSFUL_EMAIL, GetPortalID); foreach (var messageTemplate in messageTemplates) { var linqActivationTokenValues = messageTokenDB.sp_GetActivationSuccessfulTokenValue(user.UserName, GetPortalID); CommonFunction comm = new CommonFunction(); DataTable dtActivationSuccessfulTokenValues = comm.LINQToDataTable(linqActivationTokenValues); 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; } } ACTIVATION_INFORMATION.Text = GetSageMessage("UserRegistration", "ActivationSuccessfulInfo"); //ShowMessage("", GetSageMessage("UserRegistration", "ActivationSuccessfulInfo"), "", SageMessageType.Alert); } else { ShowMessage("", GetSageMessage("UserManagement", "UserDoesNotExist"), "", SageMessageType.Alert); } } else { var template = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.ACTIVATION_FAIL_INFORMATION, GetPortalID).SingleOrDefault(); 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); } } }
protected void Page_Load(object sender, EventArgs e) { SageFrameConfig pagebase = new SageFrameConfig(); IsUseFriendlyUrls = pagebase.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls); hypGotoLogin.Text = GetSageMessage("UserRegistration", "GoToLogin"); if (IsUseFriendlyUrls) { if (GetPortalID > 1) { hypGotoLogin.NavigateUrl = ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + ".aspx"); } else { hypGotoLogin.NavigateUrl = ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + ".aspx"); } } else { hypGotoLogin.NavigateUrl = ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage)); } if (!IsPostBack) { try { MessageTemplateDataContext dbMessageTemplate = new MessageTemplateDataContext(SystemSetting.SageFrameConnectionString); string ActivationCode = string.Empty; if (Request.QueryString["ActivationCode"] != null) { ActivationCode = Request.QueryString["ActivationCode"].ToString(); try { ActivationCode = EncryptionMD5.Decrypt(ActivationCode); } catch { ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("UserRegistration", "InvalidActivationCode"), "", SageMessageType.Alert); return; } UserManagementDataContext dbUser = new UserManagementDataContext(SystemSetting.SageFrameConnectionString); var sageframeuser = dbUser.sp_GetUsernameByActivationOrRecoveryCode(ActivationCode, GetPortalID).SingleOrDefault(); if (sageframeuser.CodeForUsername != null) { if (!(bool)(sageframeuser.IsAlreadyUsed)) { string UserName = _member.ActivateUser(ActivationCode, GetPortalID, GetStoreID); if (!String.IsNullOrEmpty(UserName)) { UserInfo user = _member.GetUserDetails(GetPortalID, UserName); if (user.UserExists) { var messageTemplates = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.ACTIVATION_SUCCESSFUL_EMAIL, GetPortalID); foreach (var messageTemplate in messageTemplates) { var linqActivationTokenValues = messageTokenDB.sp_GetActivationSuccessfulTokenValue(user.UserName, GetPortalID); CommonFunction comm = new CommonFunction(); DataTable dtActivationSuccessfulTokenValues = comm.LINQToDataTable(linqActivationTokenValues); 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; } } ACTIVATION_INFORMATION.Text = GetSageMessage("UserRegistration", "ActivationSuccessfulInfo"); //ShowMessage("", GetSageMessage("UserRegistration", "ActivationSuccessfulInfo"), "", SageMessageType.Alert); } else { ShowMessage("", GetSageMessage("UserManagement", "UserDoesNotExist"), "", SageMessageType.Alert); } } else { var template = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.ACTIVATION_FAIL_INFORMATION, GetPortalID).SingleOrDefault(); 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); } } }