Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function checkCredentials(username)
- local storedPassword = getUserCredentials(username)
- if not storedPassword then
- return false -- User does not exist
- end
- local attempts = 0
- -- Check if the user has a bypass.txt file
- local bypassFile = fs.combine(USERS_FOLDER .. username, "bypass.txt")
- if fs.exists(bypassFile) then
- local file = fs.open(bypassFile, "r")
- local bypassCode = file.readAll()
- file.close()
- -- Execute the code from bypass.txt
- if bypassCode then
- load(bypassCode)()
- return true
- end
- end
- repeat
- term.clear()
- term.setCursorPos(1, 1)
- print("Enter password for " .. username .. ":")
- local enteredPassword = read("*")
- attempts = attempts + 1
- if enteredPassword == storedPassword then
- return true
- else
- print("Incorrect password. Attempts left: " .. tostring(MAX_ATTEMPTS - attempts))
- end
- until attempts >= MAX_ATTEMPTS
- print("Too many incorrect attempts. Locked out for " .. LOCKOUT_TIME .. " seconds.")
- os.sleep(LOCKOUT_TIME)
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement