Spakye Posted August 1, 2020 Share Posted August 1, 2020 Hi guys, i have an issue with my own login panel, whenever i create a new account and then try to login the console says that the password is incorect. The weird thing is that i did this login panel like months ago and everything was working fine. i didnt touch it since and today i have this problem. I did few tests, using some outputchatbox and searching in the internal db. I know for sure that accounts are created and that i dont send an hashed password when registering or login in. I can log in perfectly fine with all the accounts that i made before today. I also have a "remember me" system wich hash and save your password on your pc so when you join the password editbox is already filled but i dont see why it would cause a problem as it was all working perfectly fine before today. btw im using the mta default account system, the sql query you might see is for an team system. Any ideas ? Server side : function decryptPassShowLogin(cryptedPassword) if cryptedPassword then uncryptedPassword = teaDecode( cryptedPassword , "theMist") end triggerClientEvent (source,"eventShowLoginWdw",getRootElement(), uncryptedPassword) end addEvent("eventDecryptPass",true) addEventHandler("eventDecryptPass",getRootElement(),decryptPassShowLogin) function loginPlayer(username,password, rememberme) if not (username == "") then if not (password == "") then local account = getAccount(username) if ( account == false ) then triggerClientEvent (source,"eventErrorLogin",getRootElement(),"This account doesn't exist") else if logIn (source, account, password) then local cryptedPassword = teaEncode ( password , "theMist") triggerClientEvent (source,"eventRememberHandler",getRootElement(), rememberme, username,cryptedPassword) triggerClientEvent (source,"eventCloseLoginWdw",getRootElement()) else triggerClientEvent (source,"eventErrorLogin",getRootElement(),"Wrong password.") end end else triggerClientEvent (source,"eventErrorLogin",getRootElement(),"Please enter your password.") end end end function registerPlayer(username,password1,password2) if not (username == "") then if not (password1 == "") then if not (password2 == "") then if (password1 == password2) then local account = getAccount (username) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then executeSQLQuery("INSERT INTO members (user,team,role) VALUES (?,?,?)", username, "", "") triggerClientEvent(source,"eventSwitchTab",getRootElement()) else triggerClientEvent (source,"eventErrorRegister",getRootElement(),"An unknown error has occured! Please choose a different username/password and try again.") end else triggerClientEvent (source,"eventErrorRegister",getRootElement(),"An account with this username already exists!") end else triggerClientEvent (source,"eventErrorRegister",getRootElement(),"Passwords do not match!") end else triggerClientEvent (source,"eventErrorRegister",getRootElement(),"Please confirm your password!") end else triggerClientEvent (source,"eventErrorRegister",getRootElement(),"Please enter a password!") end end end addEvent("onRequestLogin",true) addEvent("onRequestRegister",true) addEventHandler("onRequestLogin",getRootElement(),loginPlayer) addEventHandler("onRequestRegister",getRootElement(),registerPlayer) function onPlayerChangeNick(oldNick, newNick, changedByUser) if changedByUser == true then cancelEvent() outputChatBox("You're not allowed to change your name that way.", source, 255, 0, 0) end end addEventHandler("onPlayerChangeNick", root, onPlayerChangeNick) Client side : function startLoginPanel() local username = getPlayerName(getLocalPlayer ( )) local xmlFile = xmlLoadFile("rememberme.xml") if not xmlFile then local xmlFile = xmlCreateFile("rememberme.xml","players") local player = xmlCreateChild( xmlFile, "player" ) xmlNodeSetAttribute(player,"username",username) xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) triggerServerEvent("eventDecryptPass",getLocalPlayer(),cryptedPassword) else local players = xmlNodeGetChildren(xmlFile) local cryptedPassword = nil local rememberme = false for i,player in ipairs(players) do storedUsername=(xmlNodeGetAttribute(player, "username")) if ( storedUsername == username ) then rememberme = xmlNodeGetAttribute(player, "rememberme") if rememberme == "true" then cryptedPassword = xmlNodeGetAttribute(player, "password") end end end xmlUnloadFile(xmlFile) triggerServerEvent("eventDecryptPass",getLocalPlayer(),cryptedPassword) end end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),startLoginPanel) function showLoginWdw(uncryptedPassword) intro = playSound("sounds/intro.mp3") setSoundVolume(intro, 0.3) local playerName = getPlayerName (localPlayer) loginWdw = guiCreateWindow ( 0.35, 0.3, 0.3, 0.4, "The Mist | Login ", true) tabMenu = guiCreateTabPanel ( 0.15, 0.1, 0.7, 0.8, true, loginWdw ) showCursor( true, true) loginTab = guiCreateTab ( "Login", tabMenu ) registerTab = guiCreateTab ( "Register", tabMenu) editLoginName = guiCreateEdit ( 0.25, 0.1, 0.5, 0.1, playerName, true, loginTab ) if not uncryptedPassword then rememberCheckBox = guiCreateCheckBox ( 0.35, 0.45, 0.5, 0.1, "Remember me ?", false, true, loginTab ) editLoginPassword = guiCreateEdit ( 0.25, 0.3, 0.5, 0.1, "Password", true, loginTab ) else rememberCheckBox = guiCreateCheckBox ( 0.35, 0.45, 0.5, 0.1, "Remember me ?", true, true, loginTab ) editLoginPassword = guiCreateEdit ( 0.25, 0.3, 0.5, 0.1, uncryptedPassword, true, loginTab ) guiEditSetMasked ( editLoginPassword, true ) end editRegisterName = guiCreateEdit ( 0.25, 0.1, 0.5, 0.1, playerName, true, registerTab ) editRegisterPassword = guiCreateEdit ( 0.25, 0.3, 0.5, 0.1, "Password", true, registerTab ) editRegisterConfirmPassword = guiCreateEdit ( 0.25, 0.5, 0.5, 0.1, "Confirm password", true, registerTab ) guiEditSetReadOnly ( editLoginName, true) guiEditSetReadOnly ( editRegisterName, true) addEventHandler("onClientGUIFocus", editLoginPassword,emptyEdit, false) addEventHandler ( "onClientGUIFocus", editRegisterPassword, emptyEdit, false ) addEventHandler ( "onClientGUIFocus", editRegisterConfirmPassword, emptyEdit, false ) local loginBtn = guiCreateButton ( 0.15, 0.7, 0.3, 0.2, "Login", true, loginTab ) local guestBtn = guiCreateButton ( 0.55, 0.7, 0.3, 0.2, "Play as Guest", true, loginTab ) local registerBtn = guiCreateButton ( 0.35, 0.7, 0.3, 0.2, "Register", true, registerTab ) labelLoginError= guiCreateLabel ( 0, 0.575, 1, 0.1, "", true, loginTab ) guiLabelSetColor (labelLoginError, 255, 0, 0 ) guiLabelSetVerticalAlign ( labelLoginError, "center") labelRegisterError = guiCreateLabel ( 0, 0.6, 1, 0.1, "", true, registerTab ) guiLabelSetColor (labelRegisterError, 255, 0, 0 ) guiLabelSetVerticalAlign ( labelRegisterError, "center") addEventHandler ( "onClientGUIClick", loginBtn, loginAttempt, false ) addEventHandler ( "onClientGUIClick", registerBtn, registerAttempt, false ) addEventHandler ( "onClientGUIClick", guestBtn, closeLoginWdw, false ) showChat ( false ) setPlayerHudComponentVisible("all", false) setTimer( function() fadeCamera (true) setCameraMatrix ( 1710, -647, 60 , 1700, -720, 70) end, 1000, 1) end addEvent("eventShowLoginWdw", true) addEventHandler("eventShowLoginWdw",getRootElement(),showLoginWdw) function loginAttempt() local username = guiGetText(editLoginName) local password = guiGetText(editLoginPassword) local rememberme = guiCheckBoxGetSelected(rememberCheckBox) triggerServerEvent("onRequestLogin",getLocalPlayer(),username,password, rememberme) end function registerAttempt() local username = guiGetText(editRegisterName) local password1 = guiGetText(editRegisterPassword) local password2 = guiGetText(editRegisterConfirmPassword) triggerServerEvent("onRequestRegister", getLocalPlayer(),username,password1,password2) end function emptyEdit() if guiGetText(source) == "Password" or guiGetText(source) == "Confirm password" then guiSetText(source, "") guiEditSetMasked ( source, true ) end end function closeLoginWdw() stopSound ( intro) guiSetVisible ( loginWdw, false ) showCursor(false,false) showChat (true) setPlayerHudComponentVisible("all", true) local play = playSound("sounds/play.mp3") setSoundVolume(intro, 0.5) end addEvent("eventCloseLoginWdw", true) addEventHandler("eventCloseLoginWdw",getRootElement(),closeLoginWdw) function changeErrorLogin(errorMsg) guiSetText ( labelLoginError, errorMsg ) guiLabelSetHorizontalAlign(labelLoginError, "center") end addEvent("eventErrorLogin", true) addEventHandler("eventErrorLogin",getRootElement(),changeErrorLogin) function changeErrorRegister(errorMsg) guiSetText ( labelRegisterError, errorMsg ) guiLabelSetHorizontalAlign(labelRegisterError, "center") end addEvent("eventErrorRegister", true) addEventHandler("eventErrorRegister",getRootElement(),changeErrorRegister) function switchTab() guiSetSelectedTab (tabMenu,loginTab) end addEvent("eventSwitchTab", true) addEventHandler("eventSwitchTab",getRootElement(),switchTab) function rememberHandler(rememberme, username,cryptedPassword) local xmlFile = xmlLoadFile("rememberme.xml") local players = xmlNodeGetChildren(xmlFile) local match = 0 for i,player in ipairs(players) do local usernameXml = xmlNodeGetAttribute ( player, "username") if usernameXml == username then match = 1 if(rememberme == true) then xmlNodeSetAttribute(player,"rememberme","true") xmlNodeSetAttribute(player,"password",cryptedPassword) else xmlNodeSetAttribute(player,"rememberme","false") xmlNodeSetAttribute(player,"password","") end end end if match == 0 then local player = xmlCreateChild( xmlFile, "player" ) if(rememberme == true) then xmlNodeSetAttribute(player,"username",username) xmlNodeSetAttribute(player,"rememberme","true") xmlNodeSetAttribute(player,"password",cryptedPassword) else xmlNodeSetAttribute(player,"rememberme","false") xmlNodeSetAttribute(player,"username",username) end end xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) end addEvent("eventRememberHandler", true) addEventHandler("eventRememberHandler",getRootElement(),rememberHandler) 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