iteration
This commit is contained in:
parent
ea5b2af9e8
commit
c8868c6732
37
auth.lua
37
auth.lua
@ -70,3 +70,40 @@ if action == "login" then
|
||||
return
|
||||
end
|
||||
|
||||
if action == "register" then
|
||||
io.write("Username: ")
|
||||
local username = io.read()
|
||||
io.write("Password: ")
|
||||
local password = read("*")
|
||||
io.write("Confirm Password: ")
|
||||
local confirm_password = read("*")
|
||||
|
||||
if password ~= confirm_password then
|
||||
io.write("Passwords do not match\n")
|
||||
return
|
||||
end
|
||||
|
||||
local data = {
|
||||
["action"] = "register",
|
||||
["username"] = username,
|
||||
["password"] = password
|
||||
}
|
||||
|
||||
rednet.send(auth_server_id, data)
|
||||
|
||||
while true do
|
||||
id, msg = rednet.receive()
|
||||
if id == auth_server_id then
|
||||
if msg == "invalid request" then
|
||||
io.write("Invalid request\n")
|
||||
return
|
||||
elseif msg == "user already exists" then
|
||||
io.write("User already exists\n")
|
||||
return
|
||||
else
|
||||
io.write("Registered user " .. username .. "\n")
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user