Posted 06 July 2017 - 06:44 PM
I cannot seem to find the issue with these sets of code.
When I enter in the username and password fields, the program exists on the client AND the server - no matter what I put.
Seems like an easy fix.
Client Snippet
Server Snippet
When I enter in the username and password fields, the program exists on the client AND the server - no matter what I put.
Seems like an easy fix.
Client Snippet
local function lClear()
clear()
print("[Login to debit account]")
print(" ")
end
rednet.open("top")
rednet.broadcast("login")
lClear()
write("Username: ")
local user1 = read()
write("Password: ")
local pass1 = read("*")
rednet.broadcast(user1)
rednet.broadcast(pass1)
local h = rednet.receive()
if h == "notExist" then
lClear()
term.setTextColor(colors.red)
textutils.slowPrint("Invalid credentials.")
sleep(1)
term.setTextColor(colors.black)
shell.run("login")
elseif h == "exist" then
local m = rednet.receive()
if m == "correct" then
shell.run("menu")
elseif m == "incorrect" then
lClear()
term.setTextColor(colors.red)
textutils.slowPrint("Invalid credentials.")
sleep(1)
term.setTextColor(colors.black)
shell.run("login")
end
end
Server Snippet
elseif m == "login" then
local user = rednet.receive()
local pass = rednet.receive()
local i = fs.exists("users/"..user)
if i == true then
rednet.broadcast("exist")
local t = fs.open("users/"..user,"r")
local h = t.readLine()
if pass == h then
rednet.broadcast("correct")
else
rednet.broadcast("incorrect")
end
else
rednet.broadcast("notExist")
end
end