Firespider Posted August 4, 2023 Share Posted August 4, 2023 Hello, I would like to make the system check that the player has entered a good password. But for some reason this line of code is not good. server side: addEvent("attemptLogin", true) addEventHandler("attemptLogin", resourceRoot, function(username, pass) local serial = getPlayerSerial(client) dq = dbQuery(db, "SELECT * FROM accounts WHERE serial=?", serial) result = dbPoll(dq, 500) if (#result > 0) then if (result[1]["username"] == username) then if (result[2]["password"] == pass) then outputChatBox("Sikerült") else outputChatBox("Nem Sikerült") end end end end) client side: function Login() if Data[1][1] ~= "" or Data[1][2] ~= "" then triggerServerEvent("attemptLogin", resourceRoot, Data[1][1], hash("sha512", Data[1][2])) else LogAlert("EmptyRectangle") end end Error code: Link to comment
Moderators IIYAMA Posted August 4, 2023 Moderators Share Posted August 4, 2023 1 hour ago, Firespider said: But for some reason this line of code is not good. You might want to check if there is actually is data and what the data structure is. iprint("Validating variable Data:", inspect(Data)) -- debug in /debugscript 3 if not Data then return LogAlert("EmptyRectangle") end -- something is really wrong local loginCredentials = Data[1] if not loginCredentials then return LogAlert("EmptyRectangle") end -- no loginCredentials local username = loginCredentials[1] local pass = loginCredentials[2] if (username ~= "" or pass ~= "") then return LogAlert("EmptyRectangle") end -- no user name of password triggerServerEvent("attemptLogin", resourceRoot, username, hash("sha512", pass)) Link to comment
Firespider Posted August 8, 2023 Author Share Posted August 8, 2023 Thanks, but I've already created the data, so the problem won't be there. At least I think so Link to comment
FlorinSzasz Posted August 8, 2023 Share Posted August 8, 2023 26 minutes ago, Firespider said: Thanks, but I've already created the data, so the problem won't be there. At least I think so Also do you have data in db? Also u can try to loop through result and see if something comes from db. Also when u send the data from client to server check on server side if something comes outputDebugString(username) outputDebugString(password) Link to comment
Moderators IIYAMA Posted August 9, 2023 Moderators Share Posted August 9, 2023 On 08/08/2023 at 18:27, Firespider said: Thanks, but I've already created the data, so the problem won't be there. At least I think so In that case it might be handy if we know at which line + file the error is occurring. Link to comment
Firespider Posted August 10, 2023 Author Share Posted August 10, 2023 The error is on the server side in line 10. I'll send the line and, if necessary, the entire server side. if result[2]["password"] == pass then 1 Link to comment
Moderators IIYAMA Posted August 10, 2023 Moderators Share Posted August 10, 2023 9 hours ago, Firespider said: if result[2]["password"] == pass then if result[2]["password"] == pass then And if you do: if result[1]["password"] == pass then Since normally you want to get the username and password from the same row. Link to comment
Firespider Posted August 10, 2023 Author Share Posted August 10, 2023 It no longer writes an error code, but the system indicates that the password is not correct and I enter it correctly Link to comment
Moderators IIYAMA Posted August 10, 2023 Moderators Share Posted August 10, 2023 42 minutes ago, Firespider said: but the system indicates that the password is not correct and I enter it correctly In that case you might want to view those in the debug console and check how they differ. iprint(result[1]["password"], pass) Link to comment
FlorinSzasz Posted August 11, 2023 Share Posted August 11, 2023 14 hours ago, Firespider said: It no longer writes an error code, but the system indicates that the password is not correct and I enter it correctly Is your db password hashed? if yes you sould use this -> https://wiki.multitheftauto.com/wiki/PasswordVerify 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now