I would like to give a chance to the user to confirm the logout operation with a javascript-like "confirm" in a new window, and keep the current window content not changed.
I have no idea at moment, If changed it to template, the current displayed window will also redirect to the new view.
your suggestion are welcomed. thanks
the openwrt original code attached as below:
function action_logout()
local dsp = require "luci.dispatcher"
local utl = require "luci.util"
local sid = dsp.context.authsession
-- I would like to give a confirm here
if sid then
utl.ubus("session", "destroy", { ubus_rpc_session = sid })
dsp.context.urltoken.stok = nil
luci.http.header("Set-Cookie", "sysauth=%s; expires=%s; path=%s/" %{
sid, 'Thu, 01 Jan 1970 01:00:00 GMT', dsp.build_url()
})
end
luci.http.redirect(luci.dispatcher.build_url())
end
I don't think that messing with the Lua scripts is a good idea and it will not help you much.
Lua runs on the backend of the HTTP server, similar to PHP; in order to display a confirmation pop-up you will most likely need to edit the frontend code which is written in JavaScript.
Thanks Jow, that's a good solution. Is it possible to template window as a popup window (just like javascript's confirm)? it is better to keep the current window not changed instead of replacing it with the template. appreciated for your help.