public bool LoginUser(string username, string password) { if (_smoSettings.ContainsKey(CONNECTION_STRING_NAME)) { if (string.IsNullOrEmpty(username)) { throw new ArgumentNullException("Username"); } if (string.IsNullOrEmpty(password)) { throw new ArgumentNullException("Password"); } //get the user by username first then we can figure out if the password is ok TestSprocGenerator.Business.SingleTable.Bo.Account criteria = new TestSprocGenerator.Business.SingleTable.Bo.Account(_smoSettings[CONNECTION_STRING_NAME]) { AccountUsername = username, Deleted = false }; TestSprocGenerator.Business.SingleTable.Bo.List.Account searchReturned = new TestSprocGenerator.Business.SingleTable.Bo.List.Account(_smoSettings[CONNECTION_STRING_NAME]); searchReturned.FillByCriteriaExact(criteria); if (searchReturned != null && searchReturned.Count > 0) { //now that we have a user with that username we need to compare/verify the hashed password if (!string.IsNullOrEmpty(searchReturned[0].AccountPassword)) { string salt = searchReturned[0].AccountPassword.Substring(searchReturned[0].AccountPassword.Length - CommonLibrary.Security.HashSaltHelper.SALT_SIZE); string hashedPasswordAndSalt = HashSaltHelper.CreatePasswordHash(password, salt); bool passwordMatch = hashedPasswordAndSalt.Equals(searchReturned[0].AccountPassword); if (passwordMatch) { return(true); } } } return(false); } else { throw new ApplicationException("Database Connection String Not in Configuration File or not loaded from Config File"); } return(false); }
public bool AccountDeleteByCriteria(TestSprocGenerator.Business.SingleTable.Bo.Account accountModel) { if (_smoSettings.ContainsKey(CONNECTION_STRING_NAME)) { accountModel.DatabaseSmoObjectsAndSettings = _smoSettings[CONNECTION_STRING_NAME]; //do a get first cause there may be more than one record this may cause an issue TestSprocGenerator.Business.SingleTable.Bo.List.Account listReturned = new TestSprocGenerator.Business.SingleTable.Bo.List.Account(accountModel.DatabaseSmoObjectsAndSettings); listReturned.FillByCriteriaExact(accountModel); foreach (TestSprocGenerator.Business.SingleTable.Bo.Account accountToDelete in listReturned) { accountToDelete.Delete(); } return(true); } else { throw new ApplicationException("Database Connection String Not in Configuration File or not loaded from Config File"); } return(false); }