mirror of
https://github.com/MODSetter/SurfSense.git
synced 2025-09-07 21:19:07 +00:00
fix(ui): Refactor logout function in UserDropdown.tsx #199
This commit is contained in:
parent
c7d7549052
commit
d90177f6d3
1 changed files with 12 additions and 3 deletions
|
@ -36,9 +36,18 @@ export function UserDropdown({
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
if (typeof window !== 'undefined') {
|
try {
|
||||||
localStorage.removeItem('surfsense_bearer_token');
|
if (typeof window !== 'undefined') {
|
||||||
router.push('/');
|
localStorage.removeItem('surfsense_bearer_token');
|
||||||
|
router.push('/');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error during logout:', error);
|
||||||
|
// Optionally, provide user feedback
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
alert('Logout failed. Please try again.');
|
||||||
|
router.push('/');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue