0
0
Fork 0
salix-front-mindshore-fork2/src/composables/useTokenConfig.js

29 lines
792 B
JavaScript
Raw Normal View History

2024-04-19 10:09:04 +00:00
import axios from 'axios';
import { useState } from './useState';
import useNotify from './useNotify';
export function useTokenConfig() {
const state = useState();
const { notify } = useNotify();
async function fetch() {
try {
2024-04-22 05:37:35 +00:00
const { data } = await axios.get('AccessTokenConfigs/findOne', {
2024-04-19 10:09:04 +00:00
filter: { fields: ['renewInterval', 'renewPeriod'] },
});
2024-04-22 05:37:35 +00:00
if (!data) return;
state.setTokenConfig(data);
sessionStorage.setItem('renewPeriod', data.renewPeriod);
return data;
2024-04-19 10:09:04 +00:00
} catch (error) {
notify('errors.tokenConfig', 'negative');
console.error('Error fetching token config:', error);
}
}
return {
fetch,
2024-04-24 10:15:12 +00:00
state,
2024-04-19 10:09:04 +00:00
};
}