Jump to content

LOGINPANEL PROBLEM [HELP]


Recommended Posts

Hello, I have a problem when logging in. I try to see if the hashed password in the database is the same as the one entered by the player for the password, so I check if the password is correct. But even if you enter a good password and the two passwords are the same, the system always says that the password is incorrect. Can you help?

 

addEvent("login", true)
addEventHandler("login", root,
function (user, pass)
    local serial = getPlayerSerial(client)
    local dq = dbQuery(db, "SELECT * FROM accounts WHERE serial=?", serial)
    local result = dbPoll(dq, 250)

    	if (#result > 0) then
    		outputChatBox(pass)
    		local Pass = hash("sha512", pass)
    		outputChatBox(Pass)	
        if user == result[1]["username"] then
           
            if  Pass == result[1]["password"] then
                print("Sikeres bejelentkezés!")
            else
                print("Hibás jelszó!")
            end
        else
            print("Felhasználónév nem található!")
        end
    else
        print("Sikertelen bejelentkezés!")
    end            
end
)

 

Link to comment

It doesn't work just like that, you should define what a 'hash' is, and what should be applied to.
for example if you wanna encrypt your password while typing it in, you should use it somehow like this one.

if string.find(details, "hash") then
	if length > 0 then
		hash = string.rep("•", length)
	end
end

 

Link to comment
1 hour ago, Firespider said:

Doesn't Working i have a same problem 

local result = dbPoll(dq,250) -- this should 
--be like this
local result = dbPoll(dq,-1)
--Also is result[1]["password"] encrypted? when you insert it into the database?
 passwordVerify(pass,result[1]["password"]) 
---------------------------------------------------

addEvent("login", true)
addEventHandler("login", root,
function (user, pass)
    local serial = getPlayerSerial(client)
    local dq = dbQuery(db, "SELECT * FROM accounts WHERE serial=?", serial)
    local result = dbPoll(dq,-1)

    if (#result > 0) then
        if user == result[1]["username"] then
            if (passwordVerify(pass,result[1]["password"])) then
             print("Sikeres bejelentkezés!")
            else
            print("Hibás jelszó!")
       	    end
        else
            print("Felhasználónév nem található!")
        end
    else
        print("Sikertelen bejelentkezés!")
    end            
end)

    	

    	

 

Link to comment
Posted (edited)

That's the problem, I'll send the whole server page to see if it helps

 

addEvent("register", true)
addEventHandler("register", root,
function (user, pass, repass)
    local serial = getPlayerSerial(client)
    local dq = dbQuery(db, "SELECT * FROM accounts WHERE serial=?", serial)
    local result = dbPoll(dq, 250) 
    local HashPass = sha256(pass) 
    if (#result > 0) then
        print("NODUPLACITEACC")
    else
        dbExec(db, "INSERT INTO accounts (username, password, serial) VALUES (?, ?, ?)", user, HashPass, serial) 
    end 
end
)

addEvent("login", true)
addEventHandler("login", root,
function (user, pass)
    local serial = getPlayerSerial(client)
    local dq = dbQuery(db, "SELECT * FROM accounts WHERE serial=?", serial)
    local result = dbPoll(dq,250)

    if (#result > 0) then
        if user == result[1]["username"] then
            if (passwordVerify(pass,result[1]["password"])) then
             print("Sikeres bejelentkezés!")
            else
            print("Hibás jelszó!")
            end
        else
            print("Felhasználónév nem található!")
        end
    else
        print("Sikertelen bejelentkezés!")
    end            
end)

 

Edited by Firespider
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...