mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-28 23:14:34 -05:00
fix(logout): redirect to login page
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
45d379680a
commit
a6671772f2
1 changed files with 6 additions and 2 deletions
|
@ -8,6 +8,7 @@ import { clearUser } from '../../../redux/user/methods'
|
||||||
import { cypressId } from '../../../utils/cypress-attribute'
|
import { cypressId } from '../../../utils/cypress-attribute'
|
||||||
import { UiIcon } from '../../common/icons/ui-icon'
|
import { UiIcon } from '../../common/icons/ui-icon'
|
||||||
import { useUiNotifications } from '../../notifications/ui-notification-boundary'
|
import { useUiNotifications } from '../../notifications/ui-notification-boundary'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
import React, { useCallback } from 'react'
|
import React, { useCallback } from 'react'
|
||||||
import { Dropdown } from 'react-bootstrap'
|
import { Dropdown } from 'react-bootstrap'
|
||||||
import { BoxArrowRight as IconBoxArrowRight } from 'react-bootstrap-icons'
|
import { BoxArrowRight as IconBoxArrowRight } from 'react-bootstrap-icons'
|
||||||
|
@ -19,11 +20,14 @@ import { Trans, useTranslation } from 'react-i18next'
|
||||||
export const SignOutDropdownButton: React.FC = () => {
|
export const SignOutDropdownButton: React.FC = () => {
|
||||||
useTranslation()
|
useTranslation()
|
||||||
const { showErrorNotification } = useUiNotifications()
|
const { showErrorNotification } = useUiNotifications()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
const onSignOut = useCallback(() => {
|
const onSignOut = useCallback(() => {
|
||||||
clearUser()
|
clearUser()
|
||||||
doLogout().catch(showErrorNotification('login.logoutFailed'))
|
doLogout()
|
||||||
}, [showErrorNotification])
|
.then(() => router.push('/login'))
|
||||||
|
.catch(showErrorNotification('login.logoutFailed'))
|
||||||
|
}, [showErrorNotification, router])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropdown.Item dir='auto' onClick={onSignOut} {...cypressId('user-dropdown-sign-out-button')}>
|
<Dropdown.Item dir='auto' onClick={onSignOut} {...cypressId('user-dropdown-sign-out-button')}>
|
||||||
|
|
Loading…
Reference in a new issue