add some spartanAuth login stuff
This commit is contained in:
@ -13,6 +13,7 @@ export const useAuthenticationStore = defineStore('authentication', () => {
|
|||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
// TODO: make a request to the server to log out the user
|
// TODO: make a request to the server to log out the user
|
||||||
|
localStorage.removeItem('spartan-token'); // special for spartan auth
|
||||||
isAuthenticated.value = false;
|
isAuthenticated.value = false;
|
||||||
localStorage.setItem('isAuthenticated', 'false');
|
localStorage.setItem('isAuthenticated', 'false');
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
<main>
|
<main>
|
||||||
Username and password form <br>
|
Username and password form <br>
|
||||||
<button class="bg-blue-400 pl-4 pr-4 pt-2 pb-2 cursor-pointer rounded-2xl" @click="login">Login</button>
|
<button class="bg-blue-400 pl-4 pr-4 pt-2 pb-2 cursor-pointer rounded-2xl" @click="login">Login</button>
|
||||||
|
|
||||||
|
|
||||||
|
<spartan-login ref="spartanLoginRef" start-mode="webauthn" domain="http://10.0.0.12:11000" locale="en" redirect="" styles=".login-frame button {background-color: #00f000;}"></spartan-login>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -10,9 +13,24 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useAuthenticationStore } from '@/stores/authentication.ts'
|
import { useAuthenticationStore } from '@/stores/authentication.ts'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
import 'spartan-auth-widgets';
|
||||||
|
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
|
const spartanLoginRef = ref<HTMLElement|null>(null);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
spartanLoginRef?.value?.addEventListener('spartan-login', spartanLoginHandler);
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
spartanLoginRef?.value?.removeEventListener('spartan-login', spartanLoginHandler);
|
||||||
|
});
|
||||||
|
|
||||||
|
function spartanLoginHandler() {
|
||||||
|
login();
|
||||||
|
}
|
||||||
|
|
||||||
function login() {
|
function login() {
|
||||||
const authenticationStore = useAuthenticationStore();
|
const authenticationStore = useAuthenticationStore();
|
||||||
authenticationStore.login();
|
authenticationStore.login();
|
||||||
|
@ -9,7 +9,13 @@ import tailwindcss from '@tailwindcss/vite'
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
tailwindcss(),
|
tailwindcss(),
|
||||||
vue(),
|
vue({
|
||||||
|
template: {
|
||||||
|
compilerOptions: {
|
||||||
|
isCustomElement: (tag) => tag.startsWith('spartan-'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
vueDevTools(),
|
vueDevTools(),
|
||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
|
Reference in New Issue
Block a user