Jump to content

thegergo02

Members
  • Posts

    5
  • Joined

  • Last visited

Details

  • Location
    Japan
  • Occupation
    SCRIEPTKIDDIE

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

thegergo02's Achievements

Vic

Vic (3/54)

0

Reputation

  1. function _Login(username,password,thePlayer) outputChatBox( username ) outputChatBox( password ) if username and exports.tp_sql:_QuerySingle("select username from users where username = ? ",username) then if password and exports.tp_sql:_QuerySingle("select password from users where username = ? ",username) == sha256(password) then token = generateToken(35) outputChatBox( token ) user_id = exports.tp_sql:_QuerySingle("select id from users where username = ? ",username) outputChatBox(user_id) exports.tp_sql:_Exec("insert into login_tokens(token,user_id) values (?,?)",token,user_id) setElementData(thePlayer,'reglog:token',sha256(token)) outputChatBox(getElementData(thePlayer,'reglog:token',token)) outputChatBox(getElementData(thePlayer,'reglog:token',sha256(token))) return 'login:successful' else return 'login:failed:password' end else return 'login:failed:username' end end I tried to fix it, now I got 'login:failed:password'
  2. function _QuerySingle(str,...) if connection then local result = _Query(str,...) if type(result) == 'table' then return result[1] end else return false end end function _Exec(str,...) if connection then local query = dbExec(connection,str,...) return query else return false end end
  3. function _Login(thePlayer,username,password) if username and exports.tp_sql:_QuerySingle("select username from users where username = ? ",username) then if password and exports.tp_sql:_QuerySingle("select password from users where username = ? ",username) == sha256(password) then token = generateToken(35) outputChatBox( token ) user_id = exports.tp_sql:_QuerySingle("select id from users where username = ? ",username) outputChatBox(user_id) exports.tp_sql:_Exec("insert into login_tokens(token,user_id) values (?,?)",token,user_id) setElementData(thePlayer,'reglog:token',sha256(token)) outputChatBox(getElementData(thePlayer,'reglog:token',token)) outputChatBox(getElementData(thePlayer,'reglog:token',sha256(token))) return 'login:successful' else return 'login:failed:password' end else return 'login:failed:username' end end Hi! I don't know why (the username IS IN the database) but the code give me 'login:failed:username'.
×
×
  • Create New...