@@ -14,10 +14,13 @@ lastTpCoords = false;
1414-- Locals
1515local noMenuReason = ' unknown reason'
1616local awaitingReauth = false
17+ local passHelpMessage = ' To authenticate to txAdmin, use the command /txAdmin-reauth <password>.'
1718
1819--- Logic to displaying the menu auth rejected snackbar
1920local function displayAuthRejectedError ()
20- if noMenuReason == ' nui_admin_not_found' then
21+ if noMenuReason == ' password_required' then
22+ sendSnackbarMessage (' error' , passHelpMessage , false )
23+ elseif noMenuReason == ' nui_admin_not_found' then
2124 sendSnackbarMessage (' error' , ' nui_menu.misc.menu_not_admin' , true )
2225 else
2326 sendSnackbarMessage (' error' , ' nui_menu.misc.menu_auth_failed' , true , { reason = noMenuReason })
@@ -130,15 +133,25 @@ end)
130133
131134--[[ Debug Events / Commands ]]
132135-- Command/event to trigger a authentication attempt
136+ local authPassword = false
133137local function retryAuthentication ()
138+ if type (authPassword ) ~= ' string' then
139+ return
140+ end
134141 debugPrint (" ^5[AUTH] Retrying menu authentication." )
135142 menuIsAccessible = false
136143 menuPermissions = {}
137144 sendMenuMessage (' setPermissions' , menuPermissions )
138- TriggerServerEvent (' txsv:checkIfAdmin' )
145+ TriggerServerEvent (' txsv:checkIfAdmin' , authPassword )
139146end
140147RegisterNetEvent (' txcl:reAuth' , retryAuthentication )
141- RegisterCommand (' txAdmin-reauth' , function ()
148+ RegisterCommand (' txAdmin-reauth' , function (_ , args )
149+ if type (args [1 ]) ~= ' string' then
150+ sendSnackbarMessage (' error' , passHelpMessage , false )
151+ return
152+ end
153+
154+ authPassword = args [1 ]
142155 sendSnackbarMessage (' info' , ' Retrying menu authentication.' , false )
143156 awaitingReauth = true
144157 retryAuthentication ()
@@ -158,7 +171,8 @@ CreateThread(function()
158171 TriggerEvent (
159172 ' chat:addSuggestion' ,
160173 ' /txAdmin-reauth' ,
161- ' Retries to authenticate the menu NUI.'
174+ ' Retries to authenticate the menu NUI.' ,
175+ { { name = " password" , help = " 2fa secret" } }
162176 )
163177end )
164178
0 commit comments