Posted 22 April 2016 - 04:23 PM
I have a bit of a complicated question, I think.
On my friends server I am working on programming a user account system that relies off of a server so that computers that are installed with the software I am writing are able to give certain users permissions, log event data, etc.
Anyways the biggest problem I am coming across is trying to set up these accounts live. So I have a prgram on the server that will store usernames, passwords, etc. I sort of know how to store data to a file and reference it in a different program but the problem I am coming across is the part that includes multiple users. Right now because of the way the variables are, the program will only store one user at a time and then overwrite that data if a new user/ pass is put in. IRL I would use a something like mysql and since cc doesnt exactly use that, How could I implement a system that stores new users without overwriting existing users.
sort of what I have for code right now is.
and the program that I use to reference the data is….
I did use code from another post, so when i reference assert(fs.open("account", "r"), i dont know what the "r" is used for nor what assert is referencing. so if someone could enlighten me on that I would appreciate it, (I do understand fs.open is referencing the file and that the "account" is the file name.)
I know the code for the multi accounts will be considerably more complex, but I do want to give it a try.
Thank you in advance for the help :)/>
On my friends server I am working on programming a user account system that relies off of a server so that computers that are installed with the software I am writing are able to give certain users permissions, log event data, etc.
Anyways the biggest problem I am coming across is trying to set up these accounts live. So I have a prgram on the server that will store usernames, passwords, etc. I sort of know how to store data to a file and reference it in a different program but the problem I am coming across is the part that includes multiple users. Right now because of the way the variables are, the program will only store one user at a time and then overwrite that data if a new user/ pass is put in. IRL I would use a something like mysql and since cc doesnt exactly use that, How could I implement a system that stores new users without overwriting existing users.
sort of what I have for code right now is.
local name
local pass
textutils.slowPrint("Enter Username")
name = read()
textutils.slowPrint("Enter Password")
pass = read("*")
local account = {}
account.name = name
account.pass = pass
local output = textutils.serialise(account)
local handle = assert(fs.open("account", "w"), "Could Not Store Account")
handle.write(output)
handle.close()
and the program that I use to reference the data is….
local handle = assert(fs.open("account", "r"), "Could Not Load Account")
local input = handle.readAll()
handle.close
local account = textutils.unserialise(input)
print(account.name)
print(account.pass)
I did use code from another post, so when i reference assert(fs.open("account", "r"), i dont know what the "r" is used for nor what assert is referencing. so if someone could enlighten me on that I would appreciate it, (I do understand fs.open is referencing the file and that the "account" is the file name.)
I know the code for the multi accounts will be considerably more complex, but I do want to give it a try.
Thank you in advance for the help :)/>