mirror of
https://github.com/MODSetter/SurfSense.git
synced 2025-09-02 10:39:13 +00:00
Merge pull request #203 from Swapnilpatil03/fix/logout-userdropdown
fix(ui): Refactor logout function in UserDropdown.tsx #199
This commit is contained in:
commit
8e54d8bbde
1 changed files with 12 additions and 3 deletions
|
@ -36,10 +36,19 @@ export function UserDropdown({
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
|
try {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
localStorage.removeItem('surfsense_bearer_token');
|
localStorage.removeItem('surfsense_bearer_token');
|
||||||
router.push('/');
|
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('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Add table
Reference in a new issue