@@ -4,4 +4,4 @@ import { RouterView } from 'vue-router'
|
||||
|
||||
<template>
|
||||
<RouterView />
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -3,13 +3,13 @@ import store from '../store'
|
||||
|
||||
let keycloak = null
|
||||
|
||||
export function keycloakSetup() {
|
||||
export async function keycloakSetup() {
|
||||
keycloak = new Keycloak({
|
||||
url: 'https://auth.denysoft.eu/',
|
||||
realm: 'FST',
|
||||
clientId: 'frontend'
|
||||
})
|
||||
return keycloak
|
||||
await keycloak
|
||||
.init({
|
||||
onLoad: 'login-required',
|
||||
checkLoginIframe: false
|
||||
@@ -32,23 +32,10 @@ export function keycloakSetup() {
|
||||
.catch(function () {
|
||||
alert('failed to initialize')
|
||||
})
|
||||
}
|
||||
export function login() {
|
||||
keycloak.login()
|
||||
store.commit('initKeycloak', keycloak)
|
||||
store.commit('isAnonym', false)
|
||||
}
|
||||
|
||||
export function getKeycloak() {
|
||||
return keycloak
|
||||
}
|
||||
|
||||
export function isVerwaltung() {
|
||||
return keycloak.hasRealmRole('verwaltung')
|
||||
}
|
||||
|
||||
export function isEmployee() {
|
||||
return keycloak.hasRealmRole('employee')
|
||||
}
|
||||
|
||||
export function isAdmin() {
|
||||
return keycloak.hasRealmRole('admin')
|
||||
}
|
||||
|
||||
@@ -1,114 +1,119 @@
|
||||
<template>
|
||||
<div class="flex justify-between bg-gray-900 text-white pt-2 pb-3 pl-8">
|
||||
<div class="basis-1/3 logo">
|
||||
<p class="font-mono text-lg py-2">
|
||||
<RouterLink to="/">Filmstudiostube</RouterLink>
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex justify-around basis-1/3 max-md:hidden">
|
||||
<div v-if="!isAnonym">
|
||||
<p class="py-2">Aufträge</p>
|
||||
</div>
|
||||
<div v-if="!isAnonym" class="nav-item">
|
||||
<p class="py-2">Support</p>
|
||||
</div>
|
||||
<div v-if="isVerwaltung" class="nav-item">
|
||||
<p class="py-2">Administration</p>
|
||||
</div>
|
||||
<div v-if="isAnonym" class="nav-item">
|
||||
<p class="py-2">Arbeiten</p>
|
||||
</div>
|
||||
<div v-if="isAnonym" class="nav-item">
|
||||
<p class="py-2">Kontakt</p>
|
||||
</div>
|
||||
<div v-if="isAnonym" class="nav-item">
|
||||
<RouterLink to="/about">
|
||||
<p class="py-2">Über uns</p>
|
||||
</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="isAnonym" class="nav-item basis-1/6 max-md:justify-end max-md:pr-5 max-md:flex max-md:basis-3/6">
|
||||
<button class="bg-blue-600 hover:bg-blue-500 duration-300 text-white px-3 py-1 my-2 rounded" @click="login">
|
||||
Login
|
||||
</button>
|
||||
</div>
|
||||
<div class="pt-2 md:hidden" @click="openNavbar">
|
||||
<div class="space-y-1.5 pt-2 pb-2 mr-2 pr-2 pl-2 bg-slate-100 rounded">
|
||||
<span class="block w-6 h-0.5 bg-gray-500"></span>
|
||||
<span class="block w-6 h-0.5 bg-gray-500"></span>
|
||||
<span class="block w-6 h-0.5 bg-gray-500"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!isNavbarClosed">
|
||||
<ul class="bg-gray-900">
|
||||
<li v-if="!isAnonym" class="block text-md py-4 text-white text-center">
|
||||
<RouterLink to="/contracts">Aufträge</RouterLink>
|
||||
</li>
|
||||
<li v-if="!isAnonym" class="block text-md py-4 text-white text-center">
|
||||
<RouterLink to="/support">Support</RouterLink>
|
||||
</li>
|
||||
<li v-if="isVerwaltung" class="block text-md py-4 text-white text-center">
|
||||
<RouterLink to="/administration">Administration</RouterLink>
|
||||
</li>
|
||||
<li v-if="isAnonym" class="block text-md py-4 text-white text-center">
|
||||
<RouterLink to="/arbeiten">Arbeiten</RouterLink>
|
||||
</li>
|
||||
<li v-if="isAnonym" class="block text-md py-4 text-white text-center">
|
||||
<RouterLink to="/contact">Kontakt</RouterLink>
|
||||
</li>
|
||||
<li v-if="isAnonym" class="block text-md py-4 text-white text-center">
|
||||
<RouterLink to="/about">Über uns</RouterLink>
|
||||
</li>
|
||||
<li v-if="isAnonym" class="block py-2 flex justify-center">
|
||||
<button class="bg-blue-600 hover:bg-blue-500 duration-300 text-white px-3 py-1 my-2 rounded" @click="login">
|
||||
Login
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import {keycloakSetup} from "../authentication/AuthHelper";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
keycloak: this.$store.state.keycloak.keycloak,
|
||||
isAnonym: false,
|
||||
isNavbarClosed: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isVerwaltung() {
|
||||
if (this.$store.state.keycloak.keycloak === null){
|
||||
this.isAnonym = true;
|
||||
return false
|
||||
}
|
||||
return this.$store.state.keycloak.keycloak.realmAccess.roles.includes('verwaltung')
|
||||
},
|
||||
isAdmin() {
|
||||
if (this.$store.state.keycloak.keycloak === null){
|
||||
this.isAnonym = true;
|
||||
return false
|
||||
}
|
||||
return this.$store.state.keycloak.keycloak.realmAccess.roles.includes('admin')
|
||||
},
|
||||
isEmployee() {
|
||||
if (this.$store.state.keycloak.keycloak === null){
|
||||
this.isAnonym = true;
|
||||
return false
|
||||
}
|
||||
return this.$store.state.keycloak.keycloak.realmAccess.roles.includes('employeee')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
login() {
|
||||
keycloakSetup()
|
||||
},
|
||||
openNavbar(){
|
||||
this.isNavbarClosed = !this.isNavbarClosed
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex justify-between bg-gray-900 text-white pt-2 pb-3 pl-8">
|
||||
<div class="basis-1/3 logo">
|
||||
<p class="font-mono text-lg py-2">
|
||||
<RouterLink to="/">Filmstudiostube</RouterLink>
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex justify-around basis-1/3 max-md:hidden">
|
||||
<div v-if="!isAnonym">
|
||||
<RouterLink to="/contracts">
|
||||
<p class="py-2">Aufträge</p>
|
||||
</RouterLink>
|
||||
</div>
|
||||
<div v-if="!isAnonym" class="nav-item">
|
||||
<RouterLink to="/support">
|
||||
<p class="py-2">Support</p>
|
||||
</RouterLink>
|
||||
</div>
|
||||
<div v-if="isVerwaltung" class="nav-item">
|
||||
<RouterLink to="/administration">
|
||||
<p class="py-2">Administration</p>
|
||||
</RouterLink>
|
||||
</div>
|
||||
<div v-if="isAnonym" class="nav-item">
|
||||
<RouterLink to="/arbeiten">
|
||||
<p class="py-2">Arbeiten</p>
|
||||
</RouterLink>
|
||||
</div>
|
||||
<div v-if="isAnonym" class="nav-item">
|
||||
<RouterLink to="/contact">
|
||||
<p class="py-2">Kontakt</p>
|
||||
</RouterLink>
|
||||
</div>
|
||||
<div v-if="isAnonym" class="nav-item">
|
||||
<RouterLink to="/about">
|
||||
<p class="py-2">Über uns</p>
|
||||
</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="isAnonym"
|
||||
class="nav-item basis-1/6 max-md:justify-end max-md:pr-5 max-md:flex max-md:basis-3/6">
|
||||
<button
|
||||
class="bg-blue-600 hover:bg-blue-500 duration-300 text-white px-3 py-1 my-2 rounded"
|
||||
@click="login">
|
||||
Login
|
||||
</button>
|
||||
</div>
|
||||
<div class="pt-2 md:hidden" @click="openNavbar">
|
||||
<div class="space-y-1.5 pt-2 pb-2 mr-2 pr-2 pl-2 bg-slate-100 rounded">
|
||||
<span class="block w-6 h-0.5 bg-gray-500"></span>
|
||||
<span class="block w-6 h-0.5 bg-gray-500"></span>
|
||||
<span class="block w-6 h-0.5 bg-gray-500"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!isNavbarClosed">
|
||||
<ul class="bg-gray-900">
|
||||
<li v-if="!isAnonym" class="block text-md py-4 text-white text-center">
|
||||
<RouterLink to="/contracts">Aufträge</RouterLink>
|
||||
</li>
|
||||
<li v-if="!isAnonym" class="block text-md py-4 text-white text-center">
|
||||
<RouterLink to="/support">Support</RouterLink>
|
||||
</li>
|
||||
<li v-if="isVerwaltung" class="block text-md py-4 text-white text-center">
|
||||
<RouterLink to="/administration">Administration</RouterLink>
|
||||
</li>
|
||||
<li v-if="isAnonym" class="block text-md py-4 text-white text-center">
|
||||
<RouterLink to="/arbeiten">Arbeiten</RouterLink>
|
||||
</li>
|
||||
<li v-if="isAnonym" class="block text-md py-4 text-white text-center">
|
||||
<RouterLink to="/contact">Kontakt</RouterLink>
|
||||
</li>
|
||||
<li v-if="isAnonym" class="block text-md py-4 text-white text-center">
|
||||
<RouterLink to="/about">Über uns</RouterLink>
|
||||
</li>
|
||||
<li v-if="isAnonym" class="block py-2 flex justify-center">
|
||||
<button
|
||||
class="bg-blue-600 hover:bg-blue-500 duration-300 text-white px-3 py-1 my-2 rounded"
|
||||
@click="login">
|
||||
Login
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { getKeycloak, keycloakSetup } from '../authentication/AuthHelper'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
keycloak: this.$store.state.keycloak.keycloak,
|
||||
isNavbarClosed: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isVerwaltung() {
|
||||
if (getKeycloak() === null) {
|
||||
return false
|
||||
}
|
||||
return this.$store.state.keycloak.keycloak.realmAccess.roles.includes('verwaltung')
|
||||
},
|
||||
isAnonym() {
|
||||
return this.$store.state.keycloak.isAnonym
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async login() {
|
||||
if (this.$store.state.keycloak.keycloak === null) {
|
||||
await keycloakSetup()
|
||||
}
|
||||
},
|
||||
openNavbar() {
|
||||
this.isNavbarClosed = !this.isNavbarClosed
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -33,8 +33,8 @@ const router = createRouter({
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/support',
|
||||
name: 'support',
|
||||
path: '/administration',
|
||||
name: 'administration',
|
||||
// this page is lazy-loaded when the route is visited.
|
||||
component: () => import('../views/AdministrationView.vue'),
|
||||
meta: {
|
||||
@@ -87,12 +87,17 @@ const router = createRouter({
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
//if user was logged in but reloaded page. So we have all data, need only restore it
|
||||
if (store.state.keycloak.keycloak !== null && getKeycloak() === null) {
|
||||
await keycloakSetup()
|
||||
}
|
||||
|
||||
if (to.meta.requiresAuth === true) {
|
||||
if (getKeycloak() === null) {
|
||||
await keycloakSetup()
|
||||
store.commit('initKeycloak', getKeycloak())
|
||||
store.commit('isAnonym', false)
|
||||
}
|
||||
if (!getKeycloak().authenticated) {
|
||||
next('/forbidden')
|
||||
|
||||
@@ -2,11 +2,13 @@ import { createStore } from 'vuex'
|
||||
import moduleA from './moduleA.module'
|
||||
import moduleB from './moduleB.module'
|
||||
import keycloak from './keycloak.module'
|
||||
import createPersistedState from 'vuex-persistedstate'
|
||||
|
||||
export default createStore({
|
||||
modules: {
|
||||
keycloak: keycloak,
|
||||
a: moduleA,
|
||||
b: moduleB
|
||||
}
|
||||
},
|
||||
plugins: [createPersistedState()]
|
||||
})
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
export default {
|
||||
state: () => ({
|
||||
keycloak: null
|
||||
keycloak: null,
|
||||
isAnonym: true
|
||||
}),
|
||||
mutations: {
|
||||
initKeycloak(state, data) {
|
||||
state.keycloak = data
|
||||
},
|
||||
isAnonym(state, data) {
|
||||
state.isAnonym = data
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
initKeycloak({ commit }) {
|
||||
commit('initKeycloak')
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
getKeycloak(state) {
|
||||
return state.keycloak
|
||||
initKeycloak({ commit }, data) {
|
||||
commit('initKeycloak', data)
|
||||
},
|
||||
isAnonym({ commit }, data) {
|
||||
commit('isAnonym', data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<script setup>
|
||||
import Navbar from "../components/Navbar.vue";
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
mounted() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Navbar/><!-- Causes rerendering each time todo: possible use in App.vue-->
|
||||
<div class="about">
|
||||
<h1>This is a About page</h1>
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
</style>
|
||||
<script setup>
|
||||
import Navbar from '../components/Navbar.vue'
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
mounted() {}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Navbar /><!-- Causes rendering each time todo: possible use in App.vue-->
|
||||
<div class="about">
|
||||
<h1>This is a About page</h1>
|
||||
</div>
|
||||
</template>
|
||||
<style></style>
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<script setup>
|
||||
import Navbar from "../components/Navbar.vue";
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
mounted() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Navbar/><!-- Causes rerendering each time todo: possible use in App.vue-->
|
||||
<div class="about">
|
||||
<h1>This is an Administration page</h1>
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
</style>
|
||||
<script setup>
|
||||
import Navbar from '../components/Navbar.vue'
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
mounted() {}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Navbar /><!-- Causes rerendering each time todo: possible use in App.vue-->
|
||||
<div class="about">
|
||||
<h1>This is an Administration page</h1>
|
||||
</div>
|
||||
</template>
|
||||
<style></style>
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<script setup>
|
||||
import Navbar from "../components/Navbar.vue";
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
mounted() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Navbar/><!-- Causes rerendering each time todo: possible use in App.vue-->
|
||||
<div class="about">
|
||||
<h1>This is an Arbeiten page</h1>
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
</style>
|
||||
<script setup>
|
||||
import Navbar from '../components/Navbar.vue'
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
mounted() {}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Navbar /><!-- Causes rerendering each time todo: possible use in App.vue-->
|
||||
<div class="about">
|
||||
<h1>This is an Arbeiten page</h1>
|
||||
</div>
|
||||
</template>
|
||||
<style></style>
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<script setup>
|
||||
import Navbar from "../components/Navbar.vue";
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
mounted() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Navbar/><!-- Causes rerendering each time todo: possible use in App.vue-->
|
||||
<div class="about">
|
||||
<h1>This is an Contact page</h1>
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
</style>
|
||||
<script setup>
|
||||
import Navbar from '../components/Navbar.vue'
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
mounted() {}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Navbar /><!-- Causes rerendering each time todo: possible use in App.vue-->
|
||||
<div class="about">
|
||||
<h1>This is an Contact page</h1>
|
||||
</div>
|
||||
</template>
|
||||
<style></style>
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<script setup>
|
||||
import Navbar from "../components/Navbar.vue";
|
||||
import Navbar from '../components/Navbar.vue'
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
mounted() {
|
||||
}
|
||||
mounted() {}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Navbar/><!-- Causes rerendering each time todo: possible use in App.vue-->
|
||||
<Navbar /><!-- Causes rerendering each time todo: possible use in App.vue-->
|
||||
<div class="about">
|
||||
<h1>This is an Contracts page</h1>
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
</style>
|
||||
<style></style>
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<script setup>
|
||||
import Navbar from "../components/Navbar.vue";
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
mounted() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Navbar/><!-- Causes rerendering each time todo: possible use in App.vue-->
|
||||
<div class="about">
|
||||
<h1>This is a Home page</h1>
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
</style>
|
||||
<script setup>
|
||||
import Navbar from '../components/Navbar.vue'
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
mounted() {}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Navbar /><!-- Causes rerendering each time todo: possible use in App.vue-->
|
||||
<div class="about">
|
||||
<h1>This is a Home page</h1>
|
||||
</div>
|
||||
</template>
|
||||
<style></style>
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<script setup>
|
||||
import Navbar from "../components/Navbar.vue";
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
mounted() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Navbar/><!-- Causes rerendering each time todo: possible use in App.vue-->
|
||||
<div class="about">
|
||||
<h1>This is an Support page</h1>
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
</style>
|
||||
<script setup>
|
||||
import Navbar from '../components/Navbar.vue'
|
||||
</script>
|
||||
<script>
|
||||
export default {
|
||||
mounted() {}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Navbar /><!-- Causes rerendering each time todo: possible use in App.vue-->
|
||||
<div class="about">
|
||||
<h1>This is an Support page</h1>
|
||||
</div>
|
||||
</template>
|
||||
<style></style>
|
||||
|
||||
Reference in New Issue
Block a user