Esempio n. 1
0
 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!");
     }
 }
Esempio n. 2
0
 static void RunCreateCustomerCommand(CreateCustomerOptions opts)
 {
     if (Customer.IsCustomerExisting(opts.Login))
     {
         IO.DisplayWarning("Your account already exists!");
     }
     else
     {
         string password = SetUpPasswordFromKeyboard();
         password = Sha256Tools.GetHash(password);
         DBQuery.SaveNewCustomerInDb(opts.Name, opts.Login, password, opts.Location);
         Console.WriteLine("Your account has been created.");
     }
 }