Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- cs authentication
- -- prompt for login on startup
- -- specify the authentication server
- local authServer = "empty"
- -- specify the authentication protocol
- local authProtocol = "auth"
- -- specify the local credentials
- local localuser = "admin"
- local localpass = "admin"
- -- used to validate credentials with server
- function validateCredentialsRemote(user, pass)
- -- detect and open modems
- for k, v in pairs(redstone.getSides()) do
- end
- end
- -- used to validate credentials locally
- function validateCredentialsLocal(user, pass)
- if user == username and pass = password then
- local valid = true
- else
- local valid = false
- end
- return valid
- end
- -- continuously check for logins
- while true do
- -- clear the terminal
- term.clear()
- term.setCursorPos(1, 1)
- -- print a welcome message
- print("CS AUTH SCRIPT\n")
- -- prompt the user for a username and password
- write("username> ")
- local username = read()
- write("password> ")
- local password = read()
- local credentials = {username, password}
- -- check if the auth server is reachable
- local serverid = rednet.lookup(authProtocol, authServer)
- -- authenticate with the server if reachable
- if serverid ~= nil then
- print("Found")
- local valid = validateCredentialsRemote(username, password)
- -- authenticate locally if the server is not found
- else
- print("Not found")
- local valid = validateCredentialsLocal(username, password)
- end
- -- launch a shell if the credentials are valid
- if valid == true then
- shell.run("/rom/programs/shell")
- else
- print("\nInvalid credentials. Press any key to continue...")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement