release v2.0.0 #4

Merged
crimsen merged 481 commits from develop into master 2024-01-18 15:15:08 +00:00
6 changed files with 13 additions and 28 deletions
Showing only changes of commit ba485f87c5 - Show all commits

View File

@ -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);

View File

@ -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)
);

View File

@ -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 {

View File

@ -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,

View File

@ -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;
},

View File

@ -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);
}