auth evaluation bugfix
This commit is contained in:
parent
f598516ed0
commit
8c1bff3a20
@ -138,7 +138,7 @@
|
|||||||
},
|
},
|
||||||
evalAuthentication: function () {
|
evalAuthentication: function () {
|
||||||
this.$store.commit('auth/SET_AUTHENTICATED');
|
this.$store.commit('auth/SET_AUTHENTICATED');
|
||||||
// this.$store.commit('auth/SET_USER');
|
this.$store.commit('auth/SET_USER');
|
||||||
},
|
},
|
||||||
logout: function () {
|
logout: function () {
|
||||||
console.log("logout()");
|
console.log("logout()");
|
||||||
|
|||||||
@ -11,8 +11,8 @@
|
|||||||
indicator-color="cyan-14"
|
indicator-color="cyan-14"
|
||||||
switch-indicator
|
switch-indicator
|
||||||
>
|
>
|
||||||
<q-tab name="startedCaches" label="Angefangene Caches" icon="playlist_play"/>
|
<q-tab name="startedCaches" label="Angefangen" icon="playlist_play"/>
|
||||||
<q-tab name="finishedCaches" label="Beendete Caches" icon="playlist_add_check"/>
|
<q-tab name="finishedCaches" label="Beendet" icon="playlist_add_check"/>
|
||||||
</q-tabs>
|
</q-tabs>
|
||||||
<q-separator color="grey-4"/>
|
<q-separator color="grey-4"/>
|
||||||
</div>
|
</div>
|
||||||
@ -115,7 +115,7 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
this.$store.commit('auth/SET_AUTHENTICATED');
|
// this.$store.commit('auth/SET_AUTHENTICATED');
|
||||||
this.fetchUserCaches();
|
this.fetchUserCaches();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@ -60,7 +60,7 @@
|
|||||||
label="Belohnung" size="xs"/>
|
label="Belohnung" size="xs"/>
|
||||||
<q-btn v-if="hasAdminState" @click="confirmDelete(cache.id)" unelevated color="negative" stack
|
<q-btn v-if="hasAdminState" @click="confirmDelete(cache.id)" unelevated color="negative" stack
|
||||||
icon="delete" size="xs"/>
|
icon="delete" size="xs"/>
|
||||||
<q-btn disable v-if="hasAdminState" @click="editCache(cache.id)" unelevated color="primary" stack
|
<q-btn v-if="hasAdminState" @click="editCache(cache.id)" unelevated color="primary" stack
|
||||||
icon="edit" size="xs"/>
|
icon="edit" size="xs"/>
|
||||||
<q-btn v-if="hasAdminState" @click="generateQrCodes(cache.id)" unelevated color="primary" stack
|
<q-btn v-if="hasAdminState" @click="generateQrCodes(cache.id)" unelevated color="primary" stack
|
||||||
icon="image" label="QRCodes" size="xs"/>
|
icon="image" label="QRCodes" size="xs"/>
|
||||||
@ -118,13 +118,8 @@
|
|||||||
return this.$store.getters['auth/GET_ADMINSTATE'];
|
return this.$store.getters['auth/GET_ADMINSTATE'];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeMount() {
|
|
||||||
},
|
|
||||||
|
|
||||||
async created() {
|
async created() {
|
||||||
console.log("created(): " + this.caches);
|
console.log("created(): " + this.caches);
|
||||||
this.$store.commit('auth/SET_AUTHENTICATED');
|
|
||||||
this.$store.commit('auth/SET_USER');
|
|
||||||
await this.fetchAllCaches();
|
await this.fetchAllCaches();
|
||||||
this.render = await this.fetchMyCaches();
|
this.render = await this.fetchMyCaches();
|
||||||
},
|
},
|
||||||
@ -236,7 +231,7 @@
|
|||||||
addCache() {
|
addCache() {
|
||||||
this.$router.push({path: `/cache`})
|
this.$router.push({path: `/cache`})
|
||||||
},
|
},
|
||||||
editCache() {
|
editCache(cacheID) {
|
||||||
},
|
},
|
||||||
initMap() {
|
initMap() {
|
||||||
console.log("Signalwort: " + this.pois);
|
console.log("Signalwort: " + this.pois);
|
||||||
|
|||||||
@ -296,8 +296,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
this.$store.commit('auth/SET_AUTHENTICATED');
|
// this.$store.commit('auth/SET_AUTHENTICATED');
|
||||||
this.$store.commit('auth/SET_USER');
|
// this.$store.commit('auth/SET_USER');
|
||||||
this.userName = JSON.parse(localStorage.getItem('userToken')).name;
|
this.userName = JSON.parse(localStorage.getItem('userToken')).name;
|
||||||
this.data[0].userData = this.userName;
|
this.data[0].userData = this.userName;
|
||||||
this.email = JSON.parse(localStorage.getItem('userMail'));
|
this.email = JSON.parse(localStorage.getItem('userMail'));
|
||||||
|
|||||||
@ -185,8 +185,8 @@
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
localStorage.setItem('userToken', JSON.stringify(response.data));
|
localStorage.setItem('userToken', JSON.stringify(response.data));
|
||||||
localStorage.setItem('userMail', JSON.stringify(data.email));
|
localStorage.setItem('userMail', JSON.stringify(data.email));
|
||||||
this.$store.commit('auth/SET_AUTHENTICATED');
|
// this.$store.commit('auth/SET_AUTHENTICATED');
|
||||||
this.$store.commit('auth/SET_USER');
|
// this.$store.commit('auth/SET_USER');
|
||||||
this.$router.push({path: `/overview`});
|
this.$router.push({path: `/overview`});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@ -3,18 +3,17 @@ import VueRouter from "vue-router";
|
|||||||
|
|
||||||
import routes from "./routes";
|
import routes from "./routes";
|
||||||
import {axiosInstance} from "../boot/axios";
|
import {axiosInstance} from "../boot/axios";
|
||||||
Vue.use(VueRouter);
|
|
||||||
|
|
||||||
import store from "../store/index";
|
Vue.use(VueRouter);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If not building with SSR mode, you can
|
* If not building with SSR mode, you can
|
||||||
* directly export the Router instantiation
|
* directly export the Router instantiation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default function({ store }/* { store, ssrContext } */) {
|
export default function ({store}/* { store, ssrContext } */) {
|
||||||
const Router = new VueRouter({
|
const Router = new VueRouter({
|
||||||
scrollBehavior: () => ({ x: 0, y: 0 }),
|
scrollBehavior: () => ({x: 0, y: 0}),
|
||||||
routes,
|
routes,
|
||||||
store,
|
store,
|
||||||
// Leave these as is and change from quasar.conf.js instead!
|
// Leave these as is and change from quasar.conf.js instead!
|
||||||
@ -36,20 +35,23 @@ export default function({ store }/* { store, ssrContext } */) {
|
|||||||
console.log(loggedIn);
|
console.log(loggedIn);
|
||||||
const isAdmin = loggedIn ? loggedIn.roles.find(x => x.role === "ADMIN" && x.domain === "geocaching.de") : false;
|
const isAdmin = loggedIn ? loggedIn.roles.find(x => x.role === "ADMIN" && x.domain === "geocaching.de") : false;
|
||||||
//const isAdmin = true;
|
//const isAdmin = true;
|
||||||
|
|
||||||
if (!isPublic && !loggedIn) {
|
if (!isPublic && !loggedIn) {
|
||||||
return next({
|
return next({
|
||||||
path:'/login',
|
path: '/login',
|
||||||
query: {redirect: to.fullPath} // Store the full path to redirect the user to after login
|
query: {redirect: to.fullPath} // Store the full path to redirect the user to after login
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
console.log("!isPublic && !loggedIn")
|
||||||
if ((loggedIn && onlyWhenLoggedOut) || (loggedIn && onlyAdmin && !isAdmin)) {
|
if ((loggedIn && onlyWhenLoggedOut) || (loggedIn && onlyAdmin && !isAdmin)) {
|
||||||
return next('/')
|
return next('/')
|
||||||
}
|
}
|
||||||
if (isPublic) {
|
console.log("(loggedIn && onlyWhenLoggedOut) || (loggedIn && onlyAdmin && !isAdmin)")
|
||||||
|
if (isPublic && !loggedIn) {
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
if (!isPublic && loggedIn) {
|
console.log("isPublic")
|
||||||
|
if (!onlyWhenLoggedOut && loggedIn) {
|
||||||
|
console.log("fetch data...")
|
||||||
axiosInstance.get('/api/getUser', {
|
axiosInstance.get('/api/getUser', {
|
||||||
params: {
|
params: {
|
||||||
token: loggedIn.token
|
token: loggedIn.token
|
||||||
@ -57,7 +59,6 @@ export default function({ store }/* { store, ssrContext } */) {
|
|||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log("Token valid!");
|
console.log("Token valid!");
|
||||||
store.commit('auth/SET_AUTHENTICATED');
|
|
||||||
return next();
|
return next();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@ -71,16 +72,20 @@ export default function({ store }/* { store, ssrContext } */) {
|
|||||||
store.commit('dialog/NEW_MESSAGE_DIALOG', {
|
store.commit('dialog/NEW_MESSAGE_DIALOG', {
|
||||||
message: "Ihr Token ist nicht mehr gültig. Bitte loggen Sie sich erneut ein.",
|
message: "Ihr Token ist nicht mehr gültig. Bitte loggen Sie sich erneut ein.",
|
||||||
title: "Bitte erneut anmelden.",
|
title: "Bitte erneut anmelden.",
|
||||||
color: "blue", });
|
color: "blue",
|
||||||
|
});
|
||||||
localStorage.removeItem('userToken');
|
localStorage.removeItem('userToken');
|
||||||
store.commit('auth/SET_AUTHENTICATED');
|
|
||||||
return next('/Login');
|
return next('/Login');
|
||||||
} else {
|
} else {
|
||||||
console.log("unexpected behaviour");
|
console.log("unexpected behaviour");
|
||||||
console.log(error);
|
console.log(error);
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
});
|
}).finally(() => {
|
||||||
|
console.log("finally...");
|
||||||
|
store.commit('auth/SET_AUTHENTICATED');
|
||||||
|
store.commit('auth/SET_USER');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
console.log(`isPublic: ${isPublic} \nonlyWhenLoggedOut: ${onlyWhenLoggedOut} \nonlyAdmin: ${onlyAdmin}`);
|
console.log(`isPublic: ${isPublic} \nonlyWhenLoggedOut: ${onlyWhenLoggedOut} \nonlyAdmin: ${onlyAdmin}`);
|
||||||
//return next();
|
//return next();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user