release v2.0.0 #4
|
@ -1,39 +1,70 @@
|
||||||
import { boot } from 'quasar/wrappers';
|
import { boot } from 'quasar/wrappers';
|
||||||
import { RouteRecord } from 'vue-router';
|
import { RouteRecord } from 'vue-router';
|
||||||
import { Store } from 'vuex'
|
import { Store } from 'vuex';
|
||||||
import { StateInterface } from 'src/store';
|
import { StateInterface } from 'src/store';
|
||||||
|
import { UserStateInterface } from 'src/plugins/user/store/user';
|
||||||
|
|
||||||
export default boot<Store<StateInterface>>(({ router, store }) => {
|
export default boot<Store<StateInterface>>(({ router, store }) => {
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
store.dispatch('user/loadFromLocalStorage').then(() => {
|
store
|
||||||
const user: User = store.getters['user/user'];
|
.dispatch('user/loadFromLocalStorage')
|
||||||
let permissions: string[] = [];
|
.then(() => {
|
||||||
user.roles.forEach(role => {
|
const user: FG.User = <FG.User>store.getters['user/user'];
|
||||||
permissions = permissions.concat(role.permissions)
|
const session: FG.Session = <FG.Session>store.getters['user/session'];
|
||||||
});
|
let permissions: string[] = [];
|
||||||
|
user.roles.forEach(role => {
|
||||||
if (
|
permissions = permissions.concat(role.permissions);
|
||||||
to.matched.some((record: RouteRecord) => {
|
|
||||||
// permissions is set AND has NO matching permission
|
|
||||||
return (
|
|
||||||
"permissions" in record.meta &&
|
|
||||||
(
|
|
||||||
record.meta.permissions.filter((value: string) =>
|
|
||||||
permissions.includes(value)
|
|
||||||
).length == 0
|
|
||||||
)
|
|
||||||
);
|
|
||||||
})
|
|
||||||
) {
|
|
||||||
next({
|
|
||||||
path: '/login',
|
|
||||||
query: { redirect: to.fullPath }
|
|
||||||
});
|
});
|
||||||
} else {
|
console.log('route to', to);
|
||||||
next();
|
console.log('route from', from);
|
||||||
}
|
if (to.name != 'login') {
|
||||||
}).catch(error => {
|
console.log(new Date(session.expires), new Date());
|
||||||
console.exception(error);
|
console.log(new Date(session.expires) >= new Date());
|
||||||
});
|
if (
|
||||||
})
|
new Date(session.expires) >= new Date() &&
|
||||||
|
to.matched.every((record: RouteRecord) => {
|
||||||
|
const checkedPerimssions:
|
||||||
|
| boolean
|
||||||
|
| undefined = record.meta?.permissions?.every(
|
||||||
|
(permission: FG.Permission) => {
|
||||||
|
return permissions.includes(permission);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return checkedPerimssions === undefined
|
||||||
|
? true
|
||||||
|
: checkedPerimssions;
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
next();
|
||||||
|
} else {
|
||||||
|
next({ name: 'login', query: { redirect: to.fullPath } });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (
|
||||||
|
// to.matched.some((record: RouteRecord) => {
|
||||||
|
// // permissions is set AND has NO matching permission
|
||||||
|
// return (
|
||||||
|
// 'permissions' in record.meta &&
|
||||||
|
// record.meta.permissions.filter((value: string) =>
|
||||||
|
// permissions.includes(value)
|
||||||
|
// ).length == 0
|
||||||
|
// );
|
||||||
|
// })
|
||||||
|
// ) {
|
||||||
|
// next({
|
||||||
|
// path: '/login',
|
||||||
|
// query: { redirect: to.fullPath }
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// next();
|
||||||
|
// }
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.exception(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,10 +38,13 @@
|
||||||
<q-chip
|
<q-chip
|
||||||
v-for="(plugin, index) in $flaschengeistPlugins.plugins"
|
v-for="(plugin, index) in $flaschengeistPlugins.plugins"
|
||||||
:key="'plugin' + index"
|
:key="'plugin' + index"
|
||||||
|
square
|
||||||
|
class="q-my-none q-ml-xs q-mr-none q-pr-none"
|
||||||
>
|
>
|
||||||
{{ plugin.name }}
|
{{ plugin.name }}
|
||||||
<q-separator vertical color="black" class="q-ma-xs" />
|
<q-chip dense square color="green" class="q-pa-sm, q-mr-none">
|
||||||
{{ plugin.version }}
|
{{ plugin.version }}
|
||||||
|
</q-chip>
|
||||||
</q-chip>
|
</q-chip>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-separator />
|
<q-separator />
|
||||||
|
|
|
@ -39,11 +39,32 @@
|
||||||
>
|
>
|
||||||
<template v-slot:selected-item="scope">
|
<template v-slot:selected-item="scope">
|
||||||
<q-chip v-for="(item, index) in scope.opt" :key="'item' + index">
|
<q-chip v-for="(item, index) in scope.opt" :key="'item' + index">
|
||||||
{{ item }}
|
{{ item.name }}
|
||||||
</q-chip>
|
</q-chip>
|
||||||
</template>
|
</template>
|
||||||
</q-select>
|
</q-select>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
<q-separator />
|
||||||
|
<q-card-section class="fit row justify-start content-center items-center">
|
||||||
|
<q-input
|
||||||
|
class="col-xs-12 col-sm-6 col-md-4 q-pa-sm"
|
||||||
|
label="Password"
|
||||||
|
type="password"
|
||||||
|
filled
|
||||||
|
/>
|
||||||
|
<q-input
|
||||||
|
class="col-xs-12 col-sm-6 col-md-4 q-pa-sm"
|
||||||
|
label="Neues Password"
|
||||||
|
type="password"
|
||||||
|
filled
|
||||||
|
/>
|
||||||
|
<q-input
|
||||||
|
class="col-xs-12 col-sm-6 col-md-4 q-pa-sm"
|
||||||
|
label="Wiederhole neues Password"
|
||||||
|
type="password"
|
||||||
|
filled
|
||||||
|
/>
|
||||||
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -53,7 +74,7 @@ export default defineComponent({
|
||||||
name: 'Main',
|
name: 'Main',
|
||||||
setup(_, { root: { $store } }) {
|
setup(_, { root: { $store } }) {
|
||||||
const user = computed(() => {
|
const user = computed(() => {
|
||||||
return $store.getters['user/session'].user;
|
return $store.getters['user/user'];
|
||||||
});
|
});
|
||||||
return { user };
|
return { user };
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,8 @@ import { Module, MutationTree, ActionTree, GetterTree } from 'vuex';
|
||||||
import { StateInterface } from 'src/store';
|
import { StateInterface } from 'src/store';
|
||||||
import { axios } from 'src/boot/axios';
|
import { axios } from 'src/boot/axios';
|
||||||
|
|
||||||
|
|
||||||
export interface SessionInterface {
|
export interface SessionInterface {
|
||||||
sessions: Session[];
|
sessions: FG.Session[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,16 +13,16 @@ const state: SessionInterface = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations: MutationTree<SessionInterface> = {
|
const mutations: MutationTree<SessionInterface> = {
|
||||||
setSessions (state, sessions: Session[]) {
|
setSessions(state, sessions: FG.Session[]) {
|
||||||
state.sessions = sessions;
|
state.sessions = sessions;
|
||||||
},
|
},
|
||||||
setLoading (state, value: boolean) {
|
setLoading(state, value: boolean) {
|
||||||
state.loading = value;
|
state.loading = value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const actions: ActionTree<SessionInterface, StateInterface> = {
|
const actions: ActionTree<SessionInterface, StateInterface> = {
|
||||||
getSessions ({ commit, rootGetters }) {
|
getSessions({ commit, rootGetters }) {
|
||||||
console.log(rootGetters);
|
console.log(rootGetters);
|
||||||
commit('setLoading', true);
|
commit('setLoading', true);
|
||||||
axios
|
axios
|
||||||
|
@ -39,7 +38,7 @@ const actions: ActionTree<SessionInterface, StateInterface> = {
|
||||||
commit('setLoading', false);
|
commit('setLoading', false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
deleteSession ({ commit, dispatch }, token: string) {
|
deleteSession({ commit, dispatch }, token: string) {
|
||||||
commit('setLoading', true);
|
commit('setLoading', true);
|
||||||
console.log('axios', axios);
|
console.log('axios', axios);
|
||||||
axios
|
axios
|
||||||
|
@ -57,10 +56,10 @@ const actions: ActionTree<SessionInterface, StateInterface> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getters: GetterTree<SessionInterface, StateInterface> = {
|
const getters: GetterTree<SessionInterface, StateInterface> = {
|
||||||
sessions (state) {
|
sessions(state) {
|
||||||
return state.sessions;
|
return state.sessions;
|
||||||
},
|
},
|
||||||
loading (state) {
|
loading(state) {
|
||||||
return state.loading;
|
return state.loading;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue