Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Structure Username Password Age Email
- users_array = [["username1", "password1", 19, "email@gmail.com"],
- ["myuser2","mypass2",21,"Awesome.ninja@aol.co.uk"],
- ["Mr. P-teo", "secretPass", 23, "hidden_email@gmail.com"]]
- user_array_rows = users_array.length
- #input
- print "Username: "
- user_name = gets.chomp!
- print "Password: "
- user_password = gets.chomp!
- if(user_name.length > 0 && user_password.length > 0)
- #move on to user validation
- count = 0
- #check user and pass agains stored user pass combos
- while count <= user_array_rows
- if(user_name == users_array[count][0] && user_password == users_array[count][1])
- count = user_array_rows + 1
- puts "Welcome to your account #{user_name}"
- logged_in = true
- end
- count += 1
- end
- #Check if logged in
- if(!logged_in)
- puts "Login attempt unsuccessful!"
- end
- else
- #no use or pass entered.
- puts "Remember to enter both the username and password"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement