Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- users = [
- {username: "abel", password: "123"},
- {username: "antonio", password: "456"},
- {username: "castillo", password: "789"},
- {username: "tenera", password: "101"}
- ]
- max_attempts = 4;
- puts "Welcome to the authenticator"
- puts "-"*25
- puts
- puts "Please insert user and password"
- continue = true
- attempt_number = 0
- while continue && attempt_number < max_attempts do
- print "Username: "
- user_name = gets.chomp.downcase
- print "Password: "
- user_password = gets.chomp
- input_tuple = {username: user_name, password: user_password}
- if(users.index(input_tuple).nil?)
- puts "Credentials not correct"
- else
- p input_tuple
- attempt_number=0
- end
- puts "Press n to quit or any other key to continue: "
- option = gets.chomp
- continue = option != "n";
- attempt_number+=1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement