Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. users = [
  2. {username: "abel", password: "123"},
  3. {username: "antonio", password: "456"},
  4. {username: "castillo", password: "789"},
  5. {username: "tenera", password: "101"}
  6. ]
  7.  
  8. max_attempts = 4;
  9.  
  10.  
  11. puts "Welcome to the authenticator"
  12. puts "-"*25
  13. puts
  14. puts "Please insert user and password"
  15.  
  16. continue = true
  17. attempt_number = 0
  18. while continue && attempt_number < max_attempts do
  19. print "Username: "
  20. user_name = gets.chomp.downcase
  21. print "Password: "
  22. user_password = gets.chomp
  23. input_tuple = {username: user_name, password: user_password}
  24.  
  25. if(users.index(input_tuple).nil?)
  26. puts "Credentials not correct"
  27. else
  28. p input_tuple
  29. attempt_number=0
  30. end
  31.  
  32. puts "Press n to quit or any other key to continue: "
  33. option = gets.chomp
  34. continue = option != "n";
  35. attempt_number+=1
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement