Sinisterly
[Ruby] Login concept - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Coding (https://sinister.li/Forum-Coding--71)
+--- Thread: [Ruby] Login concept (/Thread-Ruby-Login-concept)



[Ruby] Login concept - Inori - 04-09-2015

Not sure what I'd use this for but I made a login system using some mechanics I learned ages ago in new ways. If you think of some cool ideas to use this, let me know.

Code:
#Login service concept by Touka, ©2015 puts "Select action: [1] Create Account [2] Login" act = gets.chomp system "cls" case act when "1" puts "Set Username: " user = gets.chomp system "cls" puts "Set Password: " pass = gets.chomp p1 = pass[0] pend = pass[-1] system "cls" puts "Username: #{user} Password: #{p1}▓▓▓▓▓▓#{pend} Correct? (y/n): " confirm = gets.chomp confirm.downcase! if confirm == "y" if Dir.exist?("users") x = x else Dir.mkdir("users") end File.new("users\\#{user}Creds.rln", "w") File.open("users\\#{user}Creds.rln", "w") {|f| f.write("#{user} : #{pass}")} else exit end when "2" def login system "cls" puts "Enter Username:" user = gets.chomp system "cls" puts "Enter Password:" pass = gets.chomp comp = "#{user} : #{pass}" system "cls" file = File.open("users\\#{user}Creds.rln") passcheck = file.read if comp == passcheck puts "Login successful." sleep else puts "Username or Password incorrect." kden = gets login end end login end