Add login route and logout page

This commit is contained in:
QiTao Weng 2022-04-09 14:39:23 -05:00
parent 0190ed596e
commit 95b517d620
3 changed files with 25 additions and 1 deletions

View File

@ -54,7 +54,7 @@ app.use(
createAuth0({ createAuth0({
domain: 'dev-ge84r-eu.us.auth0.com', domain: 'dev-ge84r-eu.us.auth0.com',
client_id: 'zHjZGg1uPws0DkQg5bRdKcDX8m6AuTZl', // eslint-disable-line camelcase client_id: 'zHjZGg1uPws0DkQg5bRdKcDX8m6AuTZl', // eslint-disable-line camelcase
redirect_uri: window.location.origin, // eslint-disable-line camelcase redirect_uri: window.location.origin + '/auth', // eslint-disable-line camelcase
}), }),
) )

19
src/pages/Auth.vue Normal file
View File

@ -0,0 +1,19 @@
<script setup lang="ts">
import { useAuth0 } from '@auth0/auth0-vue';
import router from '../router';
const { user, isAuthenticated, logout } = useAuth0();
isAuthenticated
const route = router.resolve({ path: '/'})
const absoluteURL = new URL(route.href, window.location.href).href
const leave = () => logout({ returnTo: absoluteURL })
</script>
<template>
<div>
<h2>User Profile</h2>
<code>{{ user }}</code>
<button @click="leave">Log out</button>
</div>
</template>

View File

@ -17,6 +17,11 @@ const routes = [
name: 'Editor', name: 'Editor',
component: () => import('./pages/Editor.vue'), component: () => import('./pages/Editor.vue'),
}, },
{
path:'/auth',
name: 'Auth',
component: () => import('./pages/Auth.vue'),
},
] ]
const router = createRouter({ const router = createRouter({