protected void loadData() { divResetPassword.Visible = true; divInvalid.Visible = false; DataRow dr = new AccountDataManager().getToken(acc); if (dr != null) { divResetPassword.Visible = true; divInvalid.Visible = false; Token token = new Token(); token.token = dr["token"].ToString(); token.expireTime = DateTime.Parse(dr["expiretime"].ToString()); int status = token.validateToken(param_token); if (status == 1) //valid token { lblMessage.ForeColor = System.Drawing.Color.Black; lblMessage.Text = "Please enter your new password"; } else //expired token { divResetPassword.Visible = false; divInvalid.Visible = true; } } else { divResetPassword.Visible = false; divInvalid.Visible = true; } }
protected void _btnSignin_Click(object sender, EventArgs e) { acc.email = txtEmail.Text; string password = txtPassword.Text; DataRow dr = new AccountDataManager().getAccount(acc.email); if (dr == null) { lblMessage.Text = "This email does not exist."; } else { acc.email = dr["email"].ToString(); acc.hashed_password = dr["password"].ToString(); acc.salt = dr["salt"].ToString(); if (acc.validatePassword(password)) { Response.Cookies["userid"].Value = dr["id"].ToString(); Response.Cookies["userid"].Expires = DateTime.Now.AddDays(14); Response.Redirect("/"); } else { lblMessage.Text = "Wrong email or password."; } } }
protected void loadData() { DataRow dr = new AccountDataManager().getToken(acc); if (dr != null) { Token token = new Token(); token.token = dr["token"].ToString(); token.expireTime = DateTime.Parse(dr["expiretime"].ToString()); int status = token.validateToken(param_token); if (status == 1) //valid token { new AccountDataManager().activateAccount(acc); lblTitle.Text = "Activated successfully."; lblMessage.Text = "Please login <a href=\"/Account/Signin.aspx\">here</a>"; } else { lblTitle.Text = "Invalid information"; lblMessage.Text = "If you are trying to activate your account, it seems that your token has been expired."; } } else { lblTitle.Text = "Invalid information"; lblMessage.Text = "If you are trying to activate your account, it seems that your token has been expired."; } }
public override bool ValidateUser(string username, string password) { if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { return(false); } return(AccountDataManager.AreCredentialsCorrect(username, password)); }
public override string[] GetRolesForUser(string username) { if (!HttpContext.Current.User.Identity.IsAuthenticated) { return(null); } var userRoles = new string[] { }; using (DatabaseModel dbContext = new DatabaseModel()) { var role = AccountDataManager.GetRolesForUser(username); if (!string.IsNullOrWhiteSpace(role)) { userRoles = new[] { role }; } return(userRoles.ToArray()); } }
protected void btnResetPw_Click(object sender, EventArgs e) { acc.email = txtEmail.Text; DataRow dr = new AccountDataManager().getAccount(acc.email); if (dr != null) { acc.id = int.Parse(dr["id"].ToString()); Token token = new Token(); new AccountDataManager().setToken(acc, token); sendResetPasswordEmail(acc.id, token.token); lblMessage.Text = "Reset password request was sent by email. Please check your mailbox to continue"; lblMessage.ForeColor = System.Drawing.Color.Blue; } else { lblMessage.Text = "This email does not exist"; lblMessage.ForeColor = System.Drawing.Color.Red; } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["userid"] == null) { divTimetable.Visible = false; divJumbotron.Visible = true; } else { divTimetable.Visible = true; divJumbotron.Visible = false; userid = int.Parse(Request.Cookies["userid"].Value); string email = new AccountDataManager().getAccount(userid)["email"].ToString(); lblEmail.Text = email; if (!IsPostBack) { LoadEvents(); } } }
protected void btnChangePassword_Click(object sender, EventArgs e) { currentPassword = txtCurPassword.Text; newPassword = txtPassword.Text; DataRow dr = new AccountDataManager().getAccount(acc.id); acc.email = dr["email"].ToString(); acc.hashed_password = dr["password"].ToString(); acc.salt = dr["salt"].ToString(); if (acc.validatePassword(currentPassword)) { acc.changePassword(newPassword); new AccountDataManager().updateAccount(acc); lblMessage.Text = "Changed password successfully"; lblMessage.ForeColor = System.Drawing.Color.Blue; } else { lblMessage.Text = "Incorrect current password"; lblMessage.ForeColor = System.Drawing.Color.Red; } }
public override MembershipUser GetUser(string username, bool userIsOnline) { var user = AccountDataManager.GetUser(username); return(user == null ? null : new CustomMembershipUser(user)); }