mirror of https://github.com/veypi/OneAuth.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
751 B
JavaScript
28 lines
751 B
JavaScript
|
|
import VBase from './vbase.js'
|
|
|
|
export default async ($mod) => {
|
|
// Load i18n
|
|
try {
|
|
const langs = await (await fetch($mod.scoped + '/langs.json')).json()
|
|
$mod.$i18n.load(langs)
|
|
} catch (e) {
|
|
console.error('Failed to load langs.json', e)
|
|
}
|
|
if (!$mod.$auth) {
|
|
// Initialize VBase Service
|
|
$mod.users = {}
|
|
const vbase = new VBase('vb', $mod.scoped, null, $mod.users); // Relative path
|
|
$mod.$auth = vbase;
|
|
// Wrap Axios: add auth header
|
|
vbase.wrapAxios($mod.$axios);
|
|
}
|
|
$mod.$axios.interceptors.response.use(function(response) {
|
|
return response?.data
|
|
}, function(error) {
|
|
let data = error.response ? error.response.data : error.response
|
|
return Promise.reject(data?.message || data);
|
|
});
|
|
|
|
}
|