Thomas9666

[LUA] TomOS Startup (local usercheck)

Feb 26th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. os.loadAPI("/os/api/tom")
  2. os.loadAPI("/os/api/button")
  3. tom.gui()
  4.  
  5.  
  6.  
  7. tom.gui()
  8. tom.header("Enter Username:")
  9. tom.centre("")
  10. tom.newl()
  11. for i = 1,15 do
  12. term.setBackgroundColor(colors.gray)
  13. term.write(" ")
  14. end
  15. term.setCursorPos(2,4)
  16. q = read()
  17. name = ("/os/.users/" .. q)
  18.  
  19. if fs.exists(name) then
  20. file = io.open(name, "r")
  21. pass = file:read()
  22. term.clear()
  23. tom.gui()
  24. tom.header("Enter Password")
  25. tom.newl()
  26. x,y = term.getSize()
  27. junk,y = term.getCursorPos()
  28. term.setCursorPos((x/2)-1,y)
  29. passwd = read("*")
  30. if passwd == pass then
  31. term.clear()
  32. tom.gui()
  33. welcome = ("Welcome " .. q)
  34. tom.header(welcome)
  35. tom.centre("")
  36. current = fs.open("/os/.logon","w")
  37. current.write(q)
  38. current.close()
  39. shell.run("/os/.menu")
  40. else
  41. term.clear()
  42. tom.gui()
  43. tom.header("INVALID PASSWORD")
  44. sleep(1)
  45. tom.centre("Rebooting")
  46. textutils.slowWrite("...")
  47. sleep(1)
  48. os.reboot()
  49. end
  50. else
  51. term.clear()
  52. tom.gui()
  53. tom.header("INVALID USERNAME")
  54. sleep(1)
  55. tom.centre("Rebooting")
  56. textutils.slowWrite("...")
  57. sleep(1)
  58. os.reboot()
  59. end
Add Comment
Please, Sign In to add comment