feat(frontend): Added functionality to the frontend to log in.
This commit is contained in:
parent
4a1edbb6ff
commit
a28ec22f29
20 changed files with 395 additions and 33 deletions
|
@ -1,10 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
|
||||
import {isLoggedIn, authState} from "@/store/auth-store.ts";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main>
|
||||
<b> Welcome to the dwengo homepage</b>
|
||||
<!-- TODO Placeholder implementation to test the login - replace by a more beautiful page later -->
|
||||
<b>Welcome to the dwengo homepage</b>
|
||||
<div v-if="isLoggedIn">
|
||||
<p>Hello {{authState.user?.profile.name}}!</p>
|
||||
<p>Your access token for the backend is: <code>{{authState.user?.access_token}}</code></p>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
<style scoped>
|
||||
|
|
|
@ -1,8 +1,33 @@
|
|||
<script setup lang="ts">
|
||||
|
||||
import {isLoggedIn, loginAs, logout, authState} from "@/store/auth-store.ts";
|
||||
|
||||
function loginAsStudent() {
|
||||
loginAs("student");
|
||||
}
|
||||
|
||||
function loginAsTeacher() {
|
||||
loginAs("teacher");
|
||||
}
|
||||
|
||||
function performLogout() {
|
||||
logout();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main></main>
|
||||
<main>
|
||||
<!-- TODO Placeholder implementation to test the login - replace by a more beautiful page later -->
|
||||
<div v-if="!isLoggedIn">
|
||||
<p>You are currently not logged in.</p>
|
||||
<v-btn @click="loginAsStudent">Login as student</v-btn>
|
||||
<v-btn @click="loginAsTeacher">Login as teacher</v-btn>
|
||||
</div>
|
||||
<div v-if="isLoggedIn">
|
||||
<p>You are currently logged in as {{ authState.user!.profile.name }} ({{ authState.activeRole }})</p>
|
||||
<v-btn @click="performLogout">Logout</v-btn>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
|
24
frontend/src/views/discussions/CallbackPage.vue
Normal file
24
frontend/src/views/discussions/CallbackPage.vue
Normal file
|
@ -0,0 +1,24 @@
|
|||
<script setup lang="ts">
|
||||
import {useRouter} from "vue-router";
|
||||
import {onMounted} from "vue";
|
||||
import {handleLoginCallback} from "@/store/auth-store.ts";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await handleLoginCallback();
|
||||
await router.replace("/"); // Redirect to home (or dashboard)
|
||||
} catch (error) {
|
||||
console.error("OIDC callback error:", error);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<p>Logging you in...</p>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
Loading…
Add table
Add a link
Reference in a new issue