The program on the wiki 'Login with Roaming Profiles' don't work. I wrote it on 3 PCs on the Server
3 = Password Server
4 = Client
5 = Client
and every time I want to log in on PC 4 or 5 i get 'Not authorised'
I copied the code directly from the wiki and changed the numbers of the pcs.
I hope you can help me quickly />
Password Server
Spoiler
term.clear()
term.setCursorPos(1,1)
print("This is a password server. There is no user interaction here.")
print("Please find a computer and login there.")
local firstCycle = true
local validSender = false
local modemSide = "left"
local valid = false
users = { test, test1 }
passwords = { test, test1 }
senders = { 4, 5 }
function bootUp()
rednet.open(modemSide)
end
while true do
validSender = false
if firstCycle then
bootUp()
firstCycle = false
end
senderId, message, distance = rednet.receive()
for i,v in ipairs(senders) do
if v == senderId then
validSender = true
break
end
end
if validSender then
for i,v in ipairs(users) do
if message == v then
valid = true
password = passwords[i]
else
valid = false
end
end
if valid then
rednet.send(senderId, password)
else
rednet.send(senderId, "Not Valid")
end
end
end
Client 1 & 2
Spoiler
local locker = true
local failed = true
local attempted_login = true
local password_server = 3
rednet.open("left")
while locker do
attempted_login = false
term.clear()
term.setCursorPos(1,1)
print("Welcome to a USERS PC : Roaming Profile Enabled")
print("What would you like to do?")
print("[1] Login (*)")
print("[2] Shutdown")
write("> ")
local input = read()
if input == "2" then
os.shutdown()
elseif input == "1" then
attempted_login = true
print("Please login...")
write("Username: ")
local username = read()
write("Password: ")
local password = read("*")
rednet.send(password_server, username)
senderId, message, distance = rednet.receive(5)
if password == message then
failed = false
locker = false
term.clear()
term.setCursorPos(1,1)
print("Welcome ", username)
else
print("Not authorised.")
sleep(1)
end
else
print("Command not recognised...")
sleep(2)
end
end
/<worldname>/computer/<computerid>/<prog. name>
And post all 3 codes. Much easyer to problem fix if you have the code you use
It's Server but here
Password Server
Spoiler
term.clear()
term.setCursorPos(1,1)
print("This is a password server. There is no user interaction here.")
print("Please find a computer and login there.")
local firstCycle = true
local validSender = false
local modemSide = "left"
local valid = false
users = { test, test1 }
passwords = { test, test1 }
senders = { 4, 5 }
function bootUp()
rednet.open(modemSide)
end
while true do
validSender = false
if firstCycle then
bootUp()
firstCycle = false
end
senderId, message, distance = rednet.receive()
for i,v in ipairs(senders) do
if v == senderId then
validSender = true
break
end
end
if validSender then
for i,v in ipairs(users) do
if message == v then
valid = true
password = passwords[i]
else
valid = false
end
end
if valid then
rednet.send(senderId, password)
else
rednet.send(senderId, "Not Valid")
end
end
end
Client 1 & 2
Spoiler
local locker = true
local failed = true
local attempted_login = true
local password_server = 3
rednet.open("left")
while locker do
attempted_login = false
term.clear()
term.setCursorPos(1,1)
print("Welcome to a USERS PC : Roaming Profile Enabled")
print("What would you like to do?")
print("[1] Login (*)")
print("[2] Shutdown")
write("> ")
local input = read()
if input == "2" then
os.shutdown()
elseif input == "1" then
attempted_login = true
print("Please login...")
write("Username: ")
local username = read()
write("Password: ")
local password = read("*")
rednet.send(password_server, username)
senderId, message, distance = rednet.receive(5)
if password == message then
failed = false
locker = false
term.clear()
term.setCursorPos(1,1)
print("Welcome ", username)
else
print("Not authorised.")
sleep(1)
end
else
print("Command not recognised...")
sleep(2)
end
end
I'm not sure if this ever got fixed or not but for anyone else who might be trying this and having an issue with it. Here is another issue with the script. You need to add a break to the for loop when the user and password match, otherwise the loop continues and reports false for the remaining indices in the tables.
for i,v in ipairs(users) do
if message == v then
valid = true
password = passwords[i]
break -- add this to stop the loop once you get a match
else
valid = false
end
end