Logout: app-only signout, no Microsoft account redirect
clearCache() removes MSAL tokens locally; next visit auto-SSOs silently if the user is still logged into Microsoft in the browser. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fb26d9ab56
commit
72799b64b9
1 changed files with 7 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { useNavigate, useLocation } from 'react-router-dom'
|
||||
import { useMsal } from '@azure/msal-react'
|
||||
import { useAuthStore } from '../../stores/useAuthStore'
|
||||
import api from '../../api/client'
|
||||
|
||||
const IconChevronLeft = () => (
|
||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
|
||||
|
|
@ -13,17 +13,13 @@ export default function TopBar() {
|
|||
const logout = useAuthStore(s => s.logout)
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
const { instance } = useMsal()
|
||||
|
||||
const handleLogout = async () => {
|
||||
try {
|
||||
const res = await api.post('/auth/logout', { redirectUri: window.location.origin + '/ac-helper/' })
|
||||
logout()
|
||||
if (res.data.logoutUrl) window.location.href = res.data.logoutUrl
|
||||
else navigate('/login')
|
||||
} catch {
|
||||
logout()
|
||||
navigate('/login')
|
||||
}
|
||||
const handleLogout = () => {
|
||||
// App-only logout: clear local token + MSAL cache, no Microsoft account signout
|
||||
logout()
|
||||
instance.clearCache()
|
||||
navigate('/')
|
||||
}
|
||||
|
||||
const isDashboard = location.pathname === '/'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue