Guest User

Untitled

a guest
Jun 16th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. --Checking if the current user is admin
  2. file = io.open("Mad-OS/System/CurrentUser.txt", "r")
  3. user2 = file:read("*l")
  4. access = file:read("*l")
  5. file:close()
  6.  
  7. --Getting admin password
  8. file = io.open("Mad-OS/Users/admin.txt", "r")
  9. adpass = string.reverse(file:read("*l"))
  10. file:close()
  11.  
  12. --Getting the version
  13. file = io.open("Mad-OS/System/Version.txt", "r")
  14. version = file:read("*l")
  15. file:close()
  16.  
  17. if access == "0" or access == "1" then --The current user is not admin
  18.  
  19.     print("Access denied, log in as admin to make/create users.")
  20.  
  21. else --The current user is admin
  22.    
  23.     --Showing screen and getting input
  24.     term.clear()
  25.     term.setCursorPos(1, 3)
  26.     print("          New account: Username & password")
  27.     print("")
  28.     print("          Username: ")
  29.     print("                   -----------------------")
  30.     print("          Password: ")
  31.     print("                   -----------------------")
  32.     print("          Re-enter: ")
  33.     print("                   -----------------------")
  34.     print("    Admin password: ")
  35.     print("                   -----------------------")
  36.     term.setCursorPos(21, 5)
  37.     user = io.read()
  38.     term.setCursorPos(21, 7)
  39.     pass = read("*")
  40.     term.setCursorPos(21, 9)
  41.     pass2 = read("*")
  42.     term.setCursorPos(21, 11)
  43.     adpass2 = read("*")
  44.    
  45.     if user == "nil" then
  46.    
  47.         print("\n          Invalid username")
  48.         sleep(2)
  49.         term.clear()
  50.         term.setCursorPos(1, 1)
  51.         print("Mad-OS "..version)
  52.    
  53.     else
  54.    
  55.         if (pass == pass2) and (adpass == adpass2) then  --All passwords were correct
  56.        
  57.             --Making the user with default access level
  58.             file = io.open("Mad-OS/Users/"..user..".txt", "w")
  59.             file:write(string.reverse(pass).."\n0")
  60.             file:close()
  61.            
  62.             --Logging
  63.             file = io.open("Mad-OS/Log/UserLog.txt", "a")
  64.             file:write("User "..user.." created.\n")
  65.             file:close()
  66.            
  67.             term.clear()
  68.             term.setCursorPos(1, 1)
  69.             print("Mad-OS "..version)
  70.        
  71.         else --Password mismatch
  72.        
  73.             print("\n          Password mismatch")
  74.             sleep(2)
  75.             term.clear()
  76.             term.setCursorPos(1, 1)
  77.             print("Mad-OS "..version)
  78.        
  79.         end
  80.        
  81.     end
  82.  
  83. end
Add Comment
Please, Sign In to add comment