Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This is the accounts API
- -- I made this so that my brain doesn't hurt
- -- Chock500 - 22|12|12,016HE
- os.loadAPI("chockos/fileapi")
- function checkAccountsFile()
- -- this just makes sure that the accounts file
- -- does exists to avoid errors
- if fs.exists("chockos/accounts") then
- return true
- else
- fs.makeDir("chockos/accounts")
- return false
- end
- end
- function addUser(name,pass)
- checkAccountsFile()
- if fs.exists("chockos/accounts/"..name) then
- return false
- else
- fs.makeDir("chockos/accounts/"..name)
- fs.makeDir("chockos/accounts/"..name.."/fs")
- fileapi.writeFile("chockos/accounts/"..name,"pass",pass)
- return true
- end
- end
- function removeUser(name,pass)
- -- this removes a user, but only if the password
- -- is known
- checkAccountsFile()
- if fs.exists("chockos/accounts/"..name) then
- if fileapi.readFile("chockos/accounts/"..name.."/pass") == pass then
- fs.delete("chockos/accounts/"..name)
- return true
- else
- return false
- end
- else
- return false
- end
- end
- function signIn(name,pass)
- -- checks the typed in password against the one
- -- written down in the file
- checkAccountsFile()
- if fs.exists("chockos/accounts/"..name) then
- if fileapi.readFile("chockos/accounts/"..name.."/pass") == pass then
- return true
- else
- return false
- end
- else
- return false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement