Skip to content

Commit

Permalink
Introduce the invalidCredentials for the useWorklogAuth() composable
Browse files Browse the repository at this point in the history
  • Loading branch information
LSViana committed Oct 16, 2024
1 parent ff35028 commit 8053b72
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions components/applications/worklog-tracker/useWorklogAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useCookie } from '#app'

export function useWorklogAuth() {
const authenticated = ref(false)
const invalidCredentials = ref(false)

updateAuthenticated()
useEventListener(window, 'focus', updateAuthenticated)
Expand All @@ -22,10 +23,12 @@ export function useWorklogAuth() {
})

if (response.status !== 204) {
throw new Error('Failed to authenticate')
invalidCredentials.value = true
authenticated.value = false
} else {
invalidCredentials.value = false
authenticated.value = true
}

authenticated.value = true
}

async function logout() {
Expand All @@ -42,6 +45,7 @@ export function useWorklogAuth() {

return {
authenticated,
invalidCredentials,
login,
logout
}
Expand Down

0 comments on commit 8053b72

Please sign in to comment.