This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
TheEisbaer's profile picture

Login with Roaming Profiles Don't work!

Started by TheEisbaer, 23 September 2012 - 03:30 PM
TheEisbaer #1
Posted 23 September 2012 - 05:30 PM
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 :P/>/>

Password Server
Spoilerterm.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
else
valid = false
end
end
if valid then
rednet.send(senderId, password)
else
rednet.send(senderId, "Not Valid")
end
end
end
Client 1 & 2
Spoilerlocal 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
sjele #2
Posted 23 September 2012 - 06:00 PM
If this is in ssp goto

/<worldname>/computer/<computerid>/<prog. name>
And post all 3 codes. Much easyer to problem fix if you have the code you use
TheEisbaer #3
Posted 23 September 2012 - 06:10 PM
If this is in ssp goto

/<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
Spoilerterm.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
else
valid = false
end
end
if valid then
rednet.send(senderId, password)
else
rednet.send(senderId, "Not Valid")
end
end
end
Client 1 &amp; 2
Spoilerlocal 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
Fatal_Exception #4
Posted 24 September 2012 - 12:25 AM
The usernames and passwords are strings, so they need to be in quotes.

users = { "test", "test1" }
passwords = { "test", "test1" }
Luanub #5
Posted 17 October 2012 - 12:28 PM
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