bool DoesUsernameExist(string username) { List <UserAccount> user; using (var uRepo = new UserAccountRepo(new InventoryContext())) { user = uRepo.UserAccountByUsername(username); uRepo.Complete(); } //user found if (user.Count > 0) { return(true); } else { return(false); } }
public bool DoesPasswordMatch(string correctUsername, string password) { UserAccount user; using (var uRepo = new UserAccountRepo(new InventoryContext())) { user = uRepo.UserAccountByUsername(correctUsername).First(); uRepo.Complete(); } //if password matches if (user.Password == password) { return(true); } else { return(false); } }
/// <summary> /// Arguement "password" needs to be hashed /// </summary> /// <param name="username"></param> /// <param name="password"></param> public OldAccountValidation(string username, string password) : base() { var ouV = new OldUsernameValidation(username); isOldUsernameValid = ouV.isOldUsernameValid; //if username is invalid if (!isOldUsernameValid) { //unknown if username is valid isOldPasswordValid = null; ErrorMessage += ouV.ErrorMessage; } else { var opV = new OldPasswordValidation(username, password); isOldPasswordValid = opV.isOldPasswordValid; //cast to bool now as it cant be null at this point if (!(bool)isOldPasswordValid) { //if password is invalid with correct username ErrorMessage += opV.ErrorMessage; isOldAccountValid = false; } else { //valid details isOldAccountValid = true; using (var uaRepo = new UserAccountRepo(new InventoryContext())) { account = uaRepo.UserAccountByUsername(username).First(); uaRepo.Complete(); } } } }