Prettier
This commit is contained in:
parent
6e90075db3
commit
ba485f87c5
|
@ -45,8 +45,7 @@ export default boot<Store<StateInterface>>(({ Vue, store, router }) => {
|
|||
query: { redirect: router.currentRoute.fullPath }
|
||||
});
|
||||
} else if (e.response && e.response.status == 401) {
|
||||
if (router.currentRoute.name !== 'login')
|
||||
return store.dispatch('session/clearCurrent');
|
||||
if (router.currentRoute.name !== 'login') return store.dispatch('session/clearCurrent');
|
||||
}
|
||||
}
|
||||
return Promise.reject(error);
|
||||
|
|
|
@ -3,9 +3,7 @@ import { formatDateTime } from 'src/utils/datetime';
|
|||
|
||||
export default boot(({ Vue }) => {
|
||||
Vue.filter('date', formatDateTime);
|
||||
Vue.filter('time', (date: Date, seconds = false) =>
|
||||
formatDateTime(date, false, true, seconds)
|
||||
);
|
||||
Vue.filter('time', (date: Date, seconds = false) => formatDateTime(date, false, true, seconds));
|
||||
Vue.filter('dateTime', (date: Date, seconds = false, weekday = false) =>
|
||||
formatDateTime(date, true, true, seconds, weekday)
|
||||
);
|
||||
|
|
|
@ -24,15 +24,14 @@ export default boot<Store<StateInterface>>(({ router, store }) => {
|
|||
// Check if special permissions are required
|
||||
if (
|
||||
to.matched.every((record: RouteRecord) => {
|
||||
if (!('meta' in record) || !('permissions' in record.meta))
|
||||
return true;
|
||||
if (!('meta' in record) || !('permissions' in record.meta)) return true;
|
||||
if (record.meta) {
|
||||
if ((<{ permissions: FG.Permission[] }>record.meta).permissions) {
|
||||
return (<{ permissions: FG.Permission[] }>(
|
||||
record.meta
|
||||
)).permissions.every((permission: string) => {
|
||||
return store.state.user.currentPermissions.includes(permission);
|
||||
});
|
||||
return (<{ permissions: FG.Permission[] }>record.meta).permissions.every(
|
||||
(permission: string) => {
|
||||
return store.state.user.currentPermissions.includes(permission);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -42,11 +41,7 @@ export default boot<Store<StateInterface>>(({ router, store }) => {
|
|||
next({ name: 'login', query: { redirect: to.fullPath } });
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
to.name == 'login' &&
|
||||
store.state.user.currentUser &&
|
||||
!to.params['logout']
|
||||
) {
|
||||
if (to.name == 'login' && store.state.user.currentUser && !to.params['logout']) {
|
||||
// Called login while already logged in
|
||||
void next({ name: 'dashboard' });
|
||||
} else {
|
||||
|
|
|
@ -10,9 +10,7 @@ const plugin: FG_Plugin.Plugin = {
|
|||
requiredModules: ['User'],
|
||||
requiredBackendModules: ['balance'],
|
||||
version: '0.0.1',
|
||||
store: new Map<string, Module<BalanceInterface, StateInterface>>([
|
||||
['balance', balance]
|
||||
]),
|
||||
store: new Map<string, Module<BalanceInterface, StateInterface>>([['balance', balance]]),
|
||||
widgets: [
|
||||
{
|
||||
priority: 0,
|
||||
|
|
|
@ -25,15 +25,13 @@ const state: UserStateInterface = {
|
|||
roles: [],
|
||||
permissions: [],
|
||||
currentUser: loadUserFromLocalStorage(),
|
||||
currentPermissions:
|
||||
SessionStorage.getItem<FG.Permission[]>('currentPermissions') || [],
|
||||
currentPermissions: SessionStorage.getItem<FG.Permission[]>('currentPermissions') || [],
|
||||
loading: 0
|
||||
};
|
||||
|
||||
const mutations: MutationTree<UserStateInterface> = {
|
||||
setCurrentUser(state, data: FG.User) {
|
||||
if (typeof data.birthday === 'string')
|
||||
data.birthday = new Date(data.birthday);
|
||||
if (typeof data.birthday === 'string') data.birthday = new Date(data.birthday);
|
||||
SessionStorage.set('currentUser', data);
|
||||
state.currentUser = data;
|
||||
},
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
import { Store } from 'vuex';
|
||||
import { StateInterface } from 'src/store';
|
||||
|
||||
export function hasPermission(
|
||||
permission: string,
|
||||
store: Store<StateInterface>
|
||||
) {
|
||||
export function hasPermission(permission: string, store: Store<StateInterface>) {
|
||||
return store.state.user.currentPermissions.includes(permission);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue