0
0
Fork 0

feat: refs #7308 #7308 remove warnings related to useSession

This commit is contained in:
Javier Segarra 2024-11-14 08:19:19 +01:00
parent 7dba1a1846
commit ef415d080a
3 changed files with 13 additions and 5 deletions

View File

@ -1,6 +1,7 @@
import { boot } from 'quasar/wrappers';
import qFormMixin from './qformMixin';
import keyShortcut from './keyShortcut';
import { setupAxios } from 'src/boot/axios';
import useNotify from 'src/composables/useNotify.js';
import { CanceledError } from 'axios';
@ -48,4 +49,5 @@ export default boot(({ app }) => {
notify(message ?? 'globals.error', 'negative', 'error');
};
setupAxios();
});

View File

@ -8,9 +8,13 @@ import useNotify from './useNotify';
import { useTokenConfig } from './useTokenConfig';
const TOKEN_MULTIMEDIA = 'tokenMultimedia';
const TOKEN = 'token';
let router;
export default {
setup() {
router = useRouter();
},
};
export function useSession() {
const router = useRouter();
const { notify } = useNotify();
let isCheckingToken = false;
let intervalId = null;

View File

@ -14,8 +14,8 @@ import { useUserConfig } from 'src/composables/useUserConfig';
import { useTokenConfig } from 'src/composables/useTokenConfig';
import { useAcl } from 'src/composables/useAcl';
const state = useState();
const session = useSession();
let state, session;
const { t, te } = i18n.global;
const createHistory = process.env.SERVER
@ -43,8 +43,10 @@ const Router = createRouter({
* with the Router instance.
*/
export { Router };
export default route(function (/* { store, ssrContext } */) {
export default route((/* { store, ssrContext } */) => {
Router.beforeEach(async (to, from, next) => {
state = useState();
session = useSession();
const { isLoggedIn } = session;
const outLayout = Router.options.routes[0].children.map((r) => r.name);
if (!isLoggedIn() && !outLayout.includes(to.name)) {