Simplify ProfileDropdown logout logic by redirecting to /logout and update nginx.conf to restrict /logout to GET and POST methods only.
This commit is contained in:
@@ -16,8 +16,7 @@ export default function ProfileDropdown() {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleLogout = async () => {
|
const handleLogout = async () => {
|
||||||
await fetch('/logout', { method: 'POST' })
|
window.location.href = '/logout'
|
||||||
router.push('/')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = profile.email || profile.user || 'Loading...'
|
const name = profile.email || profile.user || 'Loading...'
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ http {
|
|||||||
|
|
||||||
# Full logout: clears local session and redirects to Keycloak logout
|
# Full logout: clears local session and redirects to Keycloak logout
|
||||||
location = /logout {
|
location = /logout {
|
||||||
|
limit_except GET POST { deny all; } # allow both GET and POST
|
||||||
|
|
||||||
access_by_lua_block {
|
access_by_lua_block {
|
||||||
local session = require("resty.session").start()
|
local session = require("resty.session").start()
|
||||||
session:destroy()
|
session:destroy()
|
||||||
|
|||||||
Reference in New Issue
Block a user