mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
convenience mode to disable the auth mode for development
This commit is contained in:
parent
58a3de8fbb
commit
03e5df5ece
@ -1,2 +1,3 @@
|
|||||||
GRAPHQL_URI=http://localhost:4000/graphql
|
GRAPHQL_URI=http://localhost:4000/graphql
|
||||||
WALLET_AUTH_URL=http://localhost/vue/authenticate?token=$1
|
WALLET_AUTH_URL=http://localhost/vue/authenticate?token=$1
|
||||||
|
DEBUG_DISABLE_AUTH=false
|
||||||
@ -1,15 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<default-layout v-if="$store.state.token" />
|
<default-layout v-if="showLayout" />
|
||||||
<router-view v-else></router-view>
|
<router-view v-else></router-view>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import defaultLayout from '@/layouts/defaultLayout.vue'
|
import defaultLayout from '@/layouts/defaultLayout.vue'
|
||||||
|
import CONFIG from './config'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'app',
|
name: 'app',
|
||||||
components: { defaultLayout },
|
components: { defaultLayout },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
showLayout: CONFIG.DEBUG_DISABLE_AUTH || this.$store.state.token
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -23,6 +23,10 @@ const endpoints = {
|
|||||||
WALLET_AUTH_URL: process.env.WALLET_AUTH_URL || 'http://localhost:3000/vue/authenticate?token=$1'
|
WALLET_AUTH_URL: process.env.WALLET_AUTH_URL || 'http://localhost:3000/vue/authenticate?token=$1'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const debug = {
|
||||||
|
DEBUG_DISABLE_AUTH: process.env.DEBUG_DISABLE_AUTH === 'true' || false
|
||||||
|
}
|
||||||
|
|
||||||
const options = {}
|
const options = {}
|
||||||
|
|
||||||
const CONFIG = {
|
const CONFIG = {
|
||||||
@ -30,6 +34,7 @@ const CONFIG = {
|
|||||||
...environment,
|
...environment,
|
||||||
...endpoints,
|
...endpoints,
|
||||||
...options,
|
...options,
|
||||||
|
...debug,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CONFIG
|
export default CONFIG
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
|
import CONFIG from "../config"
|
||||||
|
|
||||||
const addNavigationGuards = (router, store) => {
|
const addNavigationGuards = (router, store) => {
|
||||||
// store token on authenticate
|
// store token on `authenticate`
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
if (to.path === '/authenticate' && to.query.token) {
|
if (to.path === '/authenticate' && to.query.token) {
|
||||||
store.commit('token',to.query.token)
|
store.commit('token',to.query.token)
|
||||||
@ -9,11 +11,13 @@ const addNavigationGuards = (router, store) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// protect all routes but not-found
|
// protect all routes but `not-found`
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
console.log('protect', to.path, from.path)
|
if (!CONFIG.DEBUG_DISABLE_AUTH && // we did not disabled the auth module for debug purposes
|
||||||
// handle authentication
|
!store.state.token && // we do not have a token
|
||||||
if (!store.state.token && to.path !== '/not-found' && to.path !== '/logout') {
|
to.path !== '/not-found' && // we are not on `not-found`
|
||||||
|
to.path !== '/logout') { // we are not on `logout`
|
||||||
|
console.log(!CONFIG.DEBUG_DISABLE_AUTH,!store.state.token,to.path !== '/not-found',to.path !== '/logout')
|
||||||
next({ path: '/not-found' })
|
next({ path: '/not-found' })
|
||||||
} else {
|
} else {
|
||||||
next()
|
next()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user