public LoginResultDto UserLogin([FromBody] UserDto userLogin) { try { using (var context = new ServiceContext()) { if (userLogin == null) { LogHelper.Error("[UserLogin]:userLogin == null"); return(LoginResultInfo(false, "登陆失败")); } var user = context.User.Where(u => u.UserName.Equals(userLogin.UserName)).FirstOrDefault(); if (user == null) { LogHelper.Error("[UserLogin]:user == null"); return(LoginResultInfo(false, "找不到用户名")); } if (!user.PassWord.Equals(MD5Password.Encryption(userLogin.PassWord))) { LogHelper.Error("[UserLogin]:PassWord is wrong"); return(LoginResultInfo(false, "密码错误")); } return(LoginResultInfo(true, "登陆成功", JustToken.token, user.UserID)); } } catch (Exception ex) { LogHelper.Error("[UserLogin]: " + ex.ToString()); return(LoginResultInfo(false, "登陆失败")); } }
static void MigrateRecord(string accountNumber, string encryptedPan, string branchCode, string cardProfileBin, string cardSerialNumber, string dateIssued, string expiryDate) { string decryptedPAN = Crypter.Decrypt(EncryptionKEY, encryptedPan); string hashedPAN = new MD5Password().CreateSecurePassword(decryptedPAN); long cardProfileID = GetCardProfileID(cardProfileBin); if (cardProfileID <= 0) { Console.WriteLine("Migration Failed for " + accountNumber + "| " + cardSerialNumber + " As a result of Invalid Bin"); InvalidCardProfileCount++; InvalidCardProfile.Add("Account Number:" + accountNumber + " | Card Profile: " + cardProfileBin); FailedEntry++; return; } if (!BranchExists(branchCode)) { Console.WriteLine("Migraton Failed for " + accountNumber + "| " + cardSerialNumber + " As a result of Invalid Branch Code"); InvalidBranchCodeCount++; InvalidBranchCode.Add("Account Number:" + accountNumber + " | Branch Code: " + branchCode); FailedEntry++; return; } if (getCardGenID(BatchName) == 0) { Console.WriteLine("Migration Failed for " + accountNumber + "| " + BatchName + " As a result of Missing Card Gen Record"); Console.WriteLine("Cant Proceed Till Card Gen Is Resolved"); FailedEntry++; return; } if (CardAlreadyMigrated(cardSerialNumber)) { Console.WriteLine("Card Already Migrated Successfully:" + cardSerialNumber + "|" + decryptedPAN); if (MigrateCardAccountRequest(encryptedPan, cardProfileID, dateIssued, branchCode, accountNumber)) { SuccessfulEntry++; } else { FailedEntry++; } } else if (MigrateCard(cardSerialNumber, encryptedPan, hashedPAN, expiryDate, dateIssued, branchCode, decryptedPAN)) { Console.WriteLine("Card Migration Successful:" + cardSerialNumber + "|" + decryptedPAN); if (MigrateCardAccountRequest(encryptedPan, cardProfileID, dateIssued, branchCode, accountNumber)) { Console.WriteLine("Card Account Created Successfully:" + accountNumber + "|" + cardSerialNumber); SuccessfulEntry++; } } else { Console.WriteLine("Card Migration Failed:" + cardSerialNumber + "|" + decryptedPAN); } }
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); }
private static bool MigrateCardAccountRequest(string encryptedPan, long cardProfileID, string dateIssued, string branchCode, string accountNumber) { string HashedPAN = new MD5Password().CreateSecurePassword(Crypter.Decrypt(EncryptionKEY, encryptedPan)); int addedCardAccountRequest; try { using (SqlCommand command = new SqlCommand()) { command.Connection = Connect; command.CommandType = CommandType.Text; command.CommandText = "INSERT into CardAccountRequests (AccountNumber, CardPAN, Type, Status, Date, BranchCode, HashedPan, InitiatorID, ApproverID, DateRequested, DateApproved, DateIssued, IssuerID, TheSchemeOwner, BatchNumber, CardProfileID, IsRegistered) VALUES (@AccountNumber, @CardPAN, @Type, @Status, @Date, @BranchCode, @HashedPan, @InitiatorID, @ApproverID, @DateRequested, @DateApproved, @DateIssued, @IssuerID, @TheSchemeOwner, @BatchNumber, @CardProfileID, @IsRegistered)"; command.Parameters.AddWithValue("@AccountNumber", accountNumber); command.Parameters.AddWithValue("@CardPAN", encryptedPan); command.Parameters.AddWithValue("@Type", "InstantIssuance"); command.Parameters.AddWithValue("@Status", "Linked"); command.Parameters.AddWithValue("@Date", DateTime.Now); command.Parameters.AddWithValue("@BranchCode", branchCode); command.Parameters.AddWithValue("@HashedPan", HashedPAN); command.Parameters.AddWithValue("@InitiatorID", UserID); command.Parameters.AddWithValue("@ApproverID", UserID); command.Parameters.AddWithValue("@DateRequested", DateTime.Now); command.Parameters.AddWithValue("@DateApproved", DateTime.Now); command.Parameters.AddWithValue("@DateIssued", dateIssued); command.Parameters.AddWithValue("@IssuerID", UserID); command.Parameters.AddWithValue("@TheSchemeOwner", "ServiceProvider"); command.Parameters.AddWithValue("@BatchNumber", BatchName); command.Parameters.AddWithValue("@CardProfileID", cardProfileID); command.Parameters.AddWithValue("@IsRegistered", 1); addedCardAccountRequest = command.ExecuteNonQuery(); } if (addedCardAccountRequest == 0) { Console.Write("Error Occurred Saving Card Account Request."); Console.WriteLine("Click Any Key To Continue"); Console.ReadKey(); return(false); } else { Console.WriteLine("Card Account Request |AccountNumber: " + accountNumber + " | HashedPAN:" + HashedPAN + " Successfully Added"); return(true); } } catch (Exception error) { Console.WriteLine("Error Occurred While Migrating Card Account Request for " + HashedPAN + " | " + encryptedPan + " | Exception:" + error); } return(false); }
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); }
public bool UserChange([FromBody] UserChangeDto userDto) { try { using (var context = new ServiceContext()) { var userEntity = context.User.Find(userDto.UserID); userEntity.PassWord = MD5Password.Encryption(userDto.PassWord); userEntity.Updatetime = DateTime.Now; context.SaveChanges(); return(true); } } catch (Exception ex) { return(false); } }
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); } }
static bool isDuplicate(string encrptedPan, string accountNumber) { string HashedPAN = new MD5Password().CreateSecurePassword(Crypter.Decrypt(EncryptionKEY, encrptedPan)); SqlCommand command = new SqlCommand("Select id from [CardAccountRequests] where HashedPan=@hashedPan", Connect); command.Parameters.AddWithValue("@hashedPan", HashedPAN); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { Console.WriteLine("Duplicate Records, Filtering by encryptedPAN: " + encrptedPan + "| Using HashedPAN:" + HashedPAN); DuplicateCardAccountRequestCount++; DuplicateCardAccountRequest.Add("Account Number:" + accountNumber + " | EncryptedPAN:" + encrptedPan + " | HashedPAN:" + HashedPAN); return(true); } } return(false); }
public string Register([FromBody] UserDto registerDto) { try { using (var context = new ServiceContext()) { if (registerDto == null) { LogHelper.Error("[Register]:registerDto == null"); return("注册失败"); } if (string.IsNullOrEmpty(registerDto.PassWord) || string.IsNullOrEmpty(registerDto.UserName)) { LogHelper.Error("[Register]:IsNullOrEmpty"); return("注册失败"); } var userEntity = context.User.Where(u => u.UserName.Equals(registerDto.UserName)).FirstOrDefault(); if (userEntity != null) { LogHelper.Error("[Register]:IsNullOrEmpty"); return("该用户名已被使用,请重新输入"); } var user = new User(); user.UserName = registerDto.UserName; user.PassWord = MD5Password.Encryption(registerDto.PassWord); user.Updatetime = DateTime.Now; context.User.Add(user); context.SaveChanges(); return("注册成功"); } } catch (Exception ex) { LogHelper.Error("[Register]: " + ex.ToString()); return("注册失败"); } }
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); } } }