protected void ResetPassword_Click(object sender, EventArgs e) { Mode = ViewMode.Reset; var email = Request["email"].ToString(); var user = UsersMapper.GetByEmailAddress(email); if (user == null) { ResetServerMessage.Text = $"<div class='alert alert-danger' role='alert'>Cannot find an account for email address: {email}</div>"; return; } if (user.ResetCode != ResetCode.Text || user.ResetCodeIssueDate == null || ((DateTime)user.ResetCodeIssueDate).AddDays(1) < DateTime.Now) { ResetServerMessage.Text = $"<div class='alert alert-danger' role='alert'>The Reset Code you entered is incorrect or has expired</div>"; return; } var returnObj = user.SetPassword(NewPassword.Text); if (!returnObj.IsError) { ResetServerMessage.Text = $"<div class='alert alert-success' role='alert'>Password for email address '{user.EmailAddress}' has been reset</div>"; EmailHelper.Send(AppSettings.SystemEmailAddress, EmailHelper.GetMailAddressesFromString(user.EmailAddress), "Password has been reset", "Your password was successfully reset for: " + URIHelper.BaseUrl); user.ResetCode = ""; returnObj = UsersMapper.Update(user); } else { ResetServerMessage.Text = $"Error resetting password: { returnObj.Error.Exception.Message }"; } }
protected void UpdateCMSAdminLogin_Click(object sender, EventArgs e) { var returnObj = new Return(); if (CMSEmailAddress.Text == "" || CMSPassword.Text == "") { Messages.Text = "Please make sure to enter a valid 'Email Address' and 'Password'"; } else { var admin = UsersMapper.GetByUserName("admin"); if (admin == null) { returnObj.Error = new Elmah.Error() { Message = "Cannot find user with username: '******'" }; } else { admin.EmailAddress = CMSEmailAddress.Text; admin.FirstName = FirstName.Text; admin.LastName = LastName.Text; admin.Password = StringHelper.Encrypt(CMSPassword.Text.Trim()); returnObj = UsersMapper.Update(admin); } if (returnObj.IsError) { Messages.Text = returnObj.Error.Message + "" + returnObj.Error.Exception.InnerException + "<br />"; } else { DisableInstallerPanel.Visible = true; Messages.Text = "Successfully updated CMS Admin Login Credentials"; MailChimpHelper mailChimpHelper = new MailChimpHelper("f23d1a1ec667a40691014801ed84f096-us15"); mailChimpHelper.AddUserToFlexDotNetCMSInstallerList(admin); } } ExecutePanel.Visible = true; }
protected void Save_OnClick(object sender, EventArgs e) { if (!canAccessSection) { return; } if (SelectedItem == null) { SelectedItem = UsersMapper.CreateObject(); } else { SelectedItem = BaseMapper.GetObjectFromContext <User>(SelectedItem); } SelectedItem.AuthenticationType = AuthType.Forms.ToString(); SelectedItem.ResetCode = ""; UpdateObjectFromFields(); Return returnObj = SelectedItem.Validate(); if (!returnObj.IsError) { if (SelectedItem.ID == 0) { returnObj = UsersMapper.Insert(SelectedItem); } else { returnObj = UsersMapper.Update(SelectedItem); } } if (returnObj.IsError) { DisplayErrorMessage("Error Saving Item", returnObj.Error); } else { DisplaySuccessMessage("Successfully Saved Item"); } }
protected void ForgotPasswordSend_Click(object sender, EventArgs e) { Mode = ViewMode.Forgot; if (string.IsNullOrEmpty(EmailAddress.Text)) { return; } var user = UsersMapper.GetByEmailAddress(EmailAddress.Text); if (user != null) { user.ResetCode = System.Web.Security.Membership.GeneratePassword(5, 0); user.ResetCodeIssueDate = DateTime.Now; var returnObj = UsersMapper.Update(user); if (!returnObj.IsError) { returnObj = EmailHelper.Send(AppSettings.SystemEmailAddress, EmailHelper.GetMailAddressesFromString(user.EmailAddress), "Password reset", $"We just recieved a password reset request, please click the following link to reset your password: {URIHelper.GetCurrentVirtualPath(true)}?mode=reset&email={user.EmailAddress}, please use the reset code: {user.ResetCode}"); if (!returnObj.IsError) { ServerMessage.Text = $"<div class='alert alert-success' role='alert'>An email has been sent to: {user.EmailAddress}</div>"; } else { ServerMessage.Text = $"<div class='alert alert-danger' role='alert'>Error sending email{returnObj.Error.Message}</div>"; } } else { ServerMessage.Text = $"<div class='alert alert-danger' role='alert'>Error sending email{returnObj.Error.Message}</div>"; } } else { ServerMessage.Text = $"<div class='alert alert-danger' role='alert'>Cannot find an account with the email address: {EmailAddress.Text}</div>"; } }