private void AddNewAdminUser() { _adminUser.UserName = txtUserName.Text; _adminUser.Password = MD5Password.MD5Hash(txtPassword.Text); _adminUser.Email = txtEmail.Text; _adminUser.FullName = txtFullName.Text; _adminUser.Active = chkbActive.Checked; _adminUserBll.InsertAdminUser(_adminUser); }
protected void btnLogin_Click(object sender, EventArgs e) { if (_adminUserBll.CheckAdminUserLogin(txtUserName.Text, MD5Password.MD5Hash(txtPassword.Text))) { var userAdmin = _adminUserBll.GetAdminUserByUsername(txtUserName.Text); BitcoinSession.AdminUser = userAdmin.Id; Response.Redirect("Default.aspx"); } else { DisplayMessage.ShowMessage("You can not login !", Page); } }
protected void btnSubmit_Click(object sender, EventArgs e) { UserBLL uBLL = new UserBLL(); var _user = uBLL.GetByEmailID(txtEmail.Text); if (_user != null) { string pass = MD5Password.GetRandomPassword(); _user.Password = MD5Password.MD5Hash(pass); uBLL.UpdatePassword(_user); var fromAddress = new MailAddress("*****@*****.**", "dobaman"); var toAddress = new MailAddress(txtEmail.Text, "dobaman"); string fromPassword = "******"; string body = "Mật khẩu mới của bạn là: " + pass; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword), Timeout = 30000 }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = "Forgot Password", Body = body, IsBodyHtml = true }) { smtp.Send(message); } ltrMsg.Text += @"<div class='alert alert-danger noborder text-center weight-400 nomargin noradius'> Password Sender To Email </div>"; } else { ltrMsg.Text += @"<div class='alert alert-danger noborder text-center weight-400 nomargin noradius'> Invalid Email! </div>"; } }
private bool CheckOldPass() { UserBLL _usBLL = new UserBLL(); var _us = _usBLL.GetByUserID(BitcoinSession.LoginMemberId); if (_us == null) { return(false); } if (_us.Password != MD5Password.MD5Hash(txtOldPass.Text)) { return(false); } return(true); }
protected void btnSubmit_Click(object sender, EventArgs e) { if (!CheckOldPass()) { ltrMsg.Text = String.Format("<div class='alert alert-warning margin-bottom-30'><strong>Warning!</strong> {0}</div>", "Old Password Incorrectly."); return; } User _us = new Bitcoin.Data.DTO.User(); _us.Password = MD5Password.MD5Hash(txtNewPass.Text); _us.UserID = BitcoinSession.LoginMemberId; UserBLL _usBLL = new UserBLL(); _usBLL.UpdatePassword(_us); Response.Redirect(Request.RawUrl); }
protected void btnSubmit_Click(object sender, EventArgs e) { ltrMsg.Text = string.Empty; if (!chkCheck.Checked) { ltrMsg.Text = String.Format("<div class='alert alert-warning margin-bottom-30'><strong>Warning!</strong> {0}</div>", "Chọn checkbox"); return; } Bitcoin.Data.DTO.User user = new Bitcoin.Data.DTO.User(); user.SponsorID = txtSponsorID.Text.Trim(); user.EmailID = txtEmailID.Text.Trim(); user.Currency = Convert.ToInt32(drdlCurrency.SelectedItem.Value); user.MobileNo = txtMobileNo.Text; user.FullName = txtFullName.Text; user.Country = drdlCountry.SelectedItem.Text; user.State = txtState.Text; user.City = txtCity.Text; user.Password = MD5Password.MD5Hash(txtPassword.Text); user.AssociateName = string.Empty; user.CreateDate = DateTime.Now; user.LevelID = 1; user.Status = 1;//Đã kích hoạt user.Rate = 15; UserBLL userBLL = new UserBLL(); int result = userBLL.InsertUser(user); switch (result) { case 1: userBLL.UpdateUserLevel(user.EmailID); break; case 9: ltrMsg.Text = String.Format("<div class='alert alert-warning margin-bottom-30'><strong>Warning!</strong> {0}</div>", "Email ID already exists."); break; case 10: ltrMsg.Text = String.Format("<div class='alert alert-warning margin-bottom-30'><strong>Warning!</strong> {0}</div>", "Sponsor ID does not exist."); break; } }
protected void btnUpdate_Click(object sender, EventArgs e) { var adminUser = _adminUserBll.GetAdminUserById(Convert.ToInt32(Request.QueryString["id"])); if (adminUser == null) { throw new ArgumentNullException("adminUser"); } else { adminUser.Password = txtPassword.Text != adminUser.Password ? MD5Password.MD5Hash(txtPassword.Text) : adminUser.Password; adminUser.Email = txtEmail.Text; adminUser.FullName = txtFullName.Text; adminUser.Active = chkbActive.Checked; _adminUserBll.UpdateAdminUser(adminUser); DisplayMessage.ShowMessage("Updated successfully !", Page); } }
protected void btnSignIn_Click(object sender, EventArgs e) { ltrMsg.Text = ""; UserBLL uBLL = new UserBLL(); bool login = uBLL.Login(txtEmail.Text, MD5Password.MD5Hash(txtPassword.Text)); if (login) { var _user = uBLL.GetByEmailID(txtEmail.Text); BitcoinSession.LoginMemberId = _user.UserID; BitcoinSession.LoginMemberEmailID = _user.EmailID; Response.Redirect("~/Member/"); } else { ltrMsg.Text += @"<div class='alert alert-danger noborder text-center weight-400 nomargin noradius'> Invalid Email or Password! </div>"; } }
private void ChangePassword() { var id = BitcoinSession.AdminUser; if (id != 0) { var adminUser = _adminUserBll.GetAdminUserById(id); if (adminUser == null) { throw new ArgumentNullException("adminUser"); } if (adminUser.Password != MD5Password.MD5Hash(txtCurrentPassword.Text)) { DisplayMessage.ShowMessage("Your current password is not valid !", Page); } else { adminUser.Password = MD5Password.MD5Hash(txtNewPassword.Text); _adminUserBll.UpdateAdminUser(adminUser); ClearControls.ClearControl(this); DisplayMessage.ShowMessage("You have been changed password successfully !", Page); } } }