This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Sane's profile picture

Simple and Clean Login

Started by Sane, 17 December 2012 - 06:26 AM
Sane #1
Posted 17 December 2012 - 07:26 AM
Well I've been working on this and I wanted to release it so I had a place to update. Next I'm adding a list for username and passwords so it's compatible with more than 1. Here you go though, it's very simple and easy to configure. I use it like so in my startup script at spawn:


shell.run("rules")
shell.run("clear")
shell.run("root")

That way if anyone tries to edit the code or display things on the monitor they need explicit access.


Here you go!

Spoiler

os.pullEvent = os.pullEventRaw
term.clear()
x, y = term.getSize()
user = "remus"
pass = "remus"
function center(text, yp)
cx = math.ceil((x/2)-(string.len(text)/2))
term.setCursorPos(cx, yp)
write(text)
end
center("Welcome to CorpOS", 1)
center("Please login to the system.", 3)
center("", 5)
write("Username: ")
local username = read()
center("", 7)
write("Password: ")
local password = read("*")
if username == (user) and password == (pass) then
  sleep(2)
  center("Login accepted.", 9)
  sleep(.7)
  shell.run("clear")
else
  sleep(2)
  center("Access denied.", 9)
  sleep(.7)
  shell.run("root")
end
immibis #2
Posted 18 December 2012 - 01:36 AM
So if I fail to login ~100 times I'll get a stack overflow error and it'll let me in?
Sane #3
Posted 19 December 2012 - 08:47 AM
What..?
Orwell #4
Posted 19 December 2012 - 09:13 AM
What..?
www.computercraft.info/forums2/index.php?/topic/4273-the-stack-and-you-how-to-not-crash-your-program ;)/>
nutcase84 #5
Posted 19 December 2012 - 09:25 AM
How secure!