♻️(frontend) introduce a logoutUrl function
Wrap the logout URL in a function for consistency with '/authenticate'.
This commit is contained in:
committed by
aleb_the_flash
parent
1c046abf5f
commit
6e20d5385f
@@ -1,2 +1,3 @@
|
|||||||
export { useUser } from './api/useUser'
|
export { useUser } from './api/useUser'
|
||||||
export { authUrl } from './utils/authUrl'
|
export { authUrl } from './utils/authUrl'
|
||||||
|
export { logoutUrl } from './utils/logoutUrl'
|
||||||
|
|||||||
5
src/frontend/src/features/auth/utils/logoutUrl.ts
Normal file
5
src/frontend/src/features/auth/utils/logoutUrl.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { apiUrl } from '@/api/apiUrl'
|
||||||
|
|
||||||
|
export const logoutUrl = () => {
|
||||||
|
return apiUrl('/logout')
|
||||||
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
import { css } from '@/styled-system/css'
|
import { css } from '@/styled-system/css'
|
||||||
import { flex } from '@/styled-system/patterns'
|
import { flex } from '@/styled-system/patterns'
|
||||||
import { apiUrl } from '@/api/apiUrl'
|
|
||||||
import { A, Badge, Text } from '@/primitives'
|
import { A, Badge, Text } from '@/primitives'
|
||||||
import { authUrl, useUser } from '@/features/auth'
|
import { authUrl, logoutUrl, useUser } from '@/features/auth'
|
||||||
|
|
||||||
export const Header = () => {
|
export const Header = () => {
|
||||||
const { user, isLoggedIn } = useUser()
|
const { user, isLoggedIn } = useUser()
|
||||||
@@ -35,7 +34,7 @@ export const Header = () => {
|
|||||||
{!!user && (
|
{!!user && (
|
||||||
<p className={flex({ gap: 1, align: 'center' })}>
|
<p className={flex({ gap: 1, align: 'center' })}>
|
||||||
<Badge>{user.email}</Badge>
|
<Badge>{user.email}</Badge>
|
||||||
<A href={apiUrl('/logout')} size="small">
|
<A href={logoutUrl()} size="small">
|
||||||
Logout
|
Logout
|
||||||
</A>
|
</A>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user