Jump to content

Bad argument ...


Marshell

Recommended Posts

Posted

Hello !! Can you help me, please ? I've got this problem : Bad argument @  "passwordVerify"   [ Expected string at argument 2, got boolean]

Thanks in advance!

 

local MINIMUM_PASSWORD_LENGTH = 6
 
local function isPasswordValid(password)
    return string.len(password) >= MINIMUM_PASSWORD_LENGTH
end
 
 
 
addCommandHandler("register", function(player, command, username, password)
    if not username or not password then
     return outputChatBox("Syntax: /" .. command .. " [nume utilizator] [ parola ]", player, 255, 205, 201)
 end
 

    if getAccount(username) then
     return outputChatBox("Un cont cu acest nume exista deja.", player, 255, 205, 201)
 end
 
 
    if not isPasswordValid(password) then
     return outputChatBox("Parola este invalida/Parola trebuie sa aiba minim 6 caractere.", player, 255, 100, 100)
 end
 

    passwordHash(password, "bcrypt", {}, function(hashedPassword)
    
 local account = addAccount(username, hashedPassword)
    setAccountData(account, "hashed_password", hashedPassword)
 
    outputChatBox("Contul tau a fost inregistrat cu succes! Acum poti folosi /accountLogin pentru a te autentifica.", player, 100, 255, 100)
 
  
 end)
end)
addEvent("auth:login-attempt", true)
addEventHandler("auth:login-attempt", root, function (username, password)
 
 
 local account = getAccount(username)
 if not account then
     return outputChatBox("Nu s-a gasit niciun cont cu acest nume si aceasta parola.", source, 255, 100, 100)
 end
 
 
 local hashedPassword = getAccountData(account, "hashed_password")
 local player = source
 passwordVerify(password, hashedPassword, function (isValid)
     if not isValid then
  return outputChatBox("Nu s-a gasit niciun cont cu acest nume si aceasta parola.", player, 255, 100, 100)
  end
 
 
  if logIn(player, account, hashedPassword) then
     return triggerClientEvent(player, "login-menu:close", player)
 end
 
 return outputChatBox("O eroare neasteptata a avut loc in timpul autentificarii.", player, 255, 100, 100)
  end)
 
end)
 
addCommandHandler("accountLogout", function(player)
    logOut(player)
end)
Posted
local MINIMUM_PASSWORD_LENGTH = 6
 
local function isPasswordValid(password)
    return string.len(password) >= MINIMUM_PASSWORD_LENGTH
end
 
 
 
addCommandHandler("register", function(player, command, username, password)
    if not username or not password then
     return outputChatBox("Syntax: /" .. command .. " [nume utilizator] [ parola ]", player, 255, 205, 201)
 end
 

    if getAccount(username) then
     return outputChatBox("Un cont cu acest nume exista deja.", player, 255, 205, 201)
 end
 
 
    if not isPasswordValid(password) then
     return outputChatBox("Parola este invalida/Parola trebuie sa aiba minim 6 caractere.", player, 255, 100, 100)
 end
 

    passwordHash(password, "bcrypt", {}, function(hashedPassword)
    
 local account = addAccount(username, hashedPassword)
    setAccountData(account, "hashed_password", hashedPassword)
 
    outputChatBox("Contul tau a fost inregistrat cu succes! Acum poti folosi /accountLogin pentru a te autentifica.", player, 100, 255, 100)
 
  
 end)
end)
addEvent("auth:login-attempt", true)
addEventHandler("auth:login-attempt", root, function (username, password)
 
 
 local account = getAccount(username)
 if not account then
     return outputChatBox("Nu s-a gasit niciun cont cu acest nume si aceasta parola.", client, 255, 100, 100)
 end
 
 
 
 
 
  if logIn(client, account, password) then
  outputChatBox("Login: Logged in", client, 255, 100, 100)
   triggerClientEvent(client, "login-menu:close", client)
 end
 

 
end)
 
addCommandHandler("accountLogout", function(player,_)
    logOut(player)
end)

NOT TESTED, i'm sure the login part is fixed though,
just make your edits (hashed stuff)

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...