-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(SettingsDrawer): add auth0 github login
- Loading branch information
1 parent
fc4505a
commit 3a8ce25
Showing
8 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<template> | ||
<v-divider /> | ||
|
||
<v-list-item | ||
:prepend-avatar="user?.picture" | ||
:prepend-icon="isAuthenticated ? undefined : 'mdi-github'" | ||
:append-icon="isAuthenticated ? 'mdi-logout-variant' : 'mdi-login-variant'" | ||
:title="isAuthenticated ? user?.name : 'Login w/ GitHub'" | ||
:subtitle="user?.email" | ||
:link="!isAuthenticated" | ||
lines="two" | ||
@click="onClick" | ||
> | ||
<template #append> | ||
<v-icon v-if="isAuthenticated" @click="onClickLogout" /> | ||
<v-icon v-else /> | ||
</template> | ||
</v-list-item> | ||
</template> | ||
<script setup> | ||
// Composables | ||
import { useAuth0 } from '@auth0/auth0-vue' | ||
const { loginWithPopup, user, isAuthenticated, logout } = useAuth0() | ||
function onClick () { | ||
if (isAuthenticated.value) return | ||
loginWithPopup() | ||
} | ||
function onClickLogout () { | ||
logout({ logoutParams: { returnTo: window.location.origin } }) | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Composables | ||
import pkg from '@auth0/auth0-vue' | ||
|
||
// Types | ||
import type { ViteSSGContext } from '@vuetify/vite-ssg' | ||
|
||
// Globals | ||
import { IN_BROWSER } from '@/util/globals' | ||
|
||
const { createAuth0 } = pkg | ||
|
||
export function useAuth0 (ctx: ViteSSGContext) { | ||
if (!IN_BROWSER) return | ||
|
||
ctx.app.use( | ||
createAuth0({ | ||
domain: import.meta.env.VITE_AUTH0_DOMAIN, | ||
clientId: import.meta.env.VITE_AUTH0_CLIENT_ID, | ||
authorizationParams: { | ||
redirect_uri: window.location.origin, | ||
}, | ||
}) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters