Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Checking if the current user is admin
- file = io.open("Mad-OS/System/CurrentUser.txt", "r")
- user2 = file:read("*l")
- access = file:read("*l")
- file:close()
- --Getting admin password
- file = io.open("Mad-OS/Users/admin.txt", "r")
- adpass = string.reverse(file:read("*l"))
- file:close()
- --Getting the version
- file = io.open("Mad-OS/System/Version.txt", "r")
- version = file:read("*l")
- file:close()
- if access == "0" or access == "1" then --The current user is not admin
- print("Access denied, log in as admin to make/create users.")
- else --The current user is admin
- --Showing screen and getting input
- term.clear()
- term.setCursorPos(1, 3)
- print(" New account: Username & password")
- print("")
- print(" Username: ")
- print(" -----------------------")
- print(" Password: ")
- print(" -----------------------")
- print(" Re-enter: ")
- print(" -----------------------")
- print(" Admin password: ")
- print(" -----------------------")
- term.setCursorPos(21, 5)
- user = io.read()
- term.setCursorPos(21, 7)
- pass = read("*")
- term.setCursorPos(21, 9)
- pass2 = read("*")
- term.setCursorPos(21, 11)
- adpass2 = read("*")
- if user == "nil" then
- print("\n Invalid username")
- sleep(2)
- term.clear()
- term.setCursorPos(1, 1)
- print("Mad-OS "..version)
- else
- if (pass == pass2) and (adpass == adpass2) then --All passwords were correct
- --Making the user with default access level
- file = io.open("Mad-OS/Users/"..user..".txt", "w")
- file:write(string.reverse(pass).."\n0")
- file:close()
- --Logging
- file = io.open("Mad-OS/Log/UserLog.txt", "a")
- file:write("User "..user.." created.\n")
- file:close()
- term.clear()
- term.setCursorPos(1, 1)
- print("Mad-OS "..version)
- else --Password mismatch
- print("\n Password mismatch")
- sleep(2)
- term.clear()
- term.setCursorPos(1, 1)
- print("Mad-OS "..version)
- end
- end
- end
Add Comment
Please, Sign In to add comment