public UserModel CheckUser(String UserName, String Password, out bool status) { //base64 pass var EncryptedPassB = System.Text.Encoding.UTF8.GetBytes(Password); var EncryptedPass = System.Convert.ToBase64String(EncryptedPassB); UserModel user = new UserModel(); status = false; DALogin da = new DALogin(); da.CheckUser(UserName); DataTable tableUsers = da.CheckUser(UserName); if (tableUsers.Rows.Count == 0) { status = false; } else { for (int i = 0; i < tableUsers.Rows.Count; i++) { if (EncryptedPass == tableUsers.Rows[i]["UserPassword"].ToString()) { status = true; user.UserId = Convert.ToInt32(tableUsers.Rows[i]["UserId"]); user.UserName = tableUsers.Rows[i]["UserName"].ToString(); user.UserPassword = tableUsers.Rows[i]["UserPassword"].ToString(); user.LastLogin = DateTime.Now; } } } return(user); }
public UserModel CheckUser(string userName, string password, out int status) { UserModel User = new UserModel(); DALogin da = new DALogin(); DataTable tableusers = da.CheckUser(userName); if (tableusers.Rows.Count == 0) { status = 1; // Username Wrong } else { if (Base64Encode(password) == tableusers.Rows[0]["UserPassword"].ToString()) { status = 2; User.UserId = Convert.ToInt32(tableusers.Rows[0]["UserId"]); User.UserName = tableusers.Rows[0]["UserName"].ToString(); User.UserPassword = tableusers.Rows[0]["UserPassword"].ToString(); User.LastLogin = DateTime.Now; da.UpdateDateTime(User.LastLogin, User.UserId); } else { status = 0; // Password Wrong } } return(User); }
public UserModel CheckUser(string userName, string password, out int status, out Boolean isActive) { isActive = false; status = 2; UserModel userModel = new UserModel(); DALogin da = new DALogin(); DataTable usersTable = da.CheckUser(userName); if (usersTable.Rows.Count == 0) { status = 1; //wrong user } else { for (int i = 0; i < usersTable.Rows.Count; i++) { if (Base64Encode(password) == usersTable.Rows[i]["UserPassword"].ToString()) { userModel.UserId = Convert.ToInt32(usersTable.Rows[i]["UserId"]); userModel.UserName = usersTable.Rows[i]["UserName"].ToString(); userModel.UserPassword = usersTable.Rows[i]["UserPassword"].ToString(); userModel.IsActive = Convert.ToBoolean(usersTable.Rows[i]["IsActive"]); userModel.UserTypeId = Convert.ToInt32(usersTable.Rows[i]["UserTypeId"]); userModel.UserInfoId = Convert.ToInt32(usersTable.Rows[i]["UserInfoId"]); isActive = userModel.IsActive; } else { status = 0; //wrong pass } } } return(userModel); }
public UserModel CheckUser(string userName, string password, out bool status) { string passwordEncrypted; var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(password); passwordEncrypted = System.Convert.ToBase64String(plainTextBytes); UserModel user = new UserModel(); status = false; DALogin da = new DALogin(); DataTable tableUsers = da.CheckUser(userName); if (tableUsers.Rows.Count == 0) { status = false; } else { for (int i = 0; i < tableUsers.Rows.Count; i++) { if (passwordEncrypted == tableUsers.Rows[i]["UserPassword"].ToString()) { user.UserId = Convert.ToInt32(tableUsers.Rows[i]["UserId"]); user.UserName = tableUsers.Rows[i]["UserName"].ToString(); user.UserPasswrod = tableUsers.Rows[i]["UserPassword"].ToString(); user.LastLogin = DateTime.Now; status = true; } } } return(user); }