Skip to content

Commit

Permalink
♻️(frontend) introduce a logoutUrl function
Browse files Browse the repository at this point in the history
Wrap the logout URL in a function for consistency with '/authenticate'.
  • Loading branch information
lebaudantoine committed Jul 17, 2024
1 parent 1c046ab commit 6e20d53
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/frontend/src/features/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { useUser } from './api/useUser'
export { authUrl } from './utils/authUrl'
export { logoutUrl } from './utils/logoutUrl'
5 changes: 5 additions & 0 deletions src/frontend/src/features/auth/utils/logoutUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { apiUrl } from '@/api/apiUrl'

export const logoutUrl = () => {
return apiUrl('/logout')
}
5 changes: 2 additions & 3 deletions src/frontend/src/layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { css } from '@/styled-system/css'
import { flex } from '@/styled-system/patterns'
import { apiUrl } from '@/api/apiUrl'
import { A, Badge, Text } from '@/primitives'
import { authUrl, useUser } from '@/features/auth'
import { authUrl, logoutUrl, useUser } from '@/features/auth'

export const Header = () => {
const { user, isLoggedIn } = useUser()
Expand Down Expand Up @@ -35,7 +34,7 @@ export const Header = () => {
{!!user && (
<p className={flex({ gap: 1, align: 'center' })}>
<Badge>{user.email}</Badge>
<A href={apiUrl('/logout')} size="small">
<A href={logoutUrl()} size="small">
Logout
</A>
</p>
Expand Down

0 comments on commit 6e20d53

Please sign in to comment.