static void RunLoginCommand(LoginOptions opts) { if (Customer.IsCustomerExisting(opts.Login)) { currentCustomer = DBQuery.getCustomerFromDbWhereLogin(opts.Login); currentCustomer.Accounts = DBQuery.GetAccountsCustomer(currentCustomer.IdCustomer); string password = "******"; int i = 0; do { Console.WriteLine("Please type in your password"); password = IO.PromptPassword(); password = Sha256Tools.GetHash(password); i++; }while ((password != currentCustomer.Password) && (i <= 2)); if (password == currentCustomer.Password) { IO.DisplayInformation("You are connected!"); } else { IO.DisplayWarning("Too many attempts, please try again later!"); Environment.Exit(1); } } else { IO.DisplayWarning("Your account doesn't exist!"); } }
public static bool IsCustomerExisting(string login) { Customer existingCustomer = DBQuery.getCustomerFromDbWhereLogin(login); if (existingCustomer == null) { return(false); } else { return(true); } }