diff --git a/src/composables/useRole.js b/src/composables/useRole.js index 0184b23da..95b585283 100644 --- a/src/composables/useRole.js +++ b/src/composables/useRole.js @@ -1,5 +1,4 @@ import { useState } from './useState'; -import { useUserConfig } from './useUserConfig'; import axios from 'axios'; export function useRole() { @@ -7,7 +6,6 @@ export function useRole() { async function fetch() { const { data } = await axios.get('VnUsers/acl'); - const userConfig = await useUserConfig().fetch(); const roles = data.roles.map((userRoles) => userRoles.role.name); const userData = { @@ -15,7 +13,6 @@ export function useRole() { name: data.user.name, nickname: data.user.nickname, lang: data.user.lang || 'es', - darkMode: userConfig.darkMode, }; state.setUser(userData); state.setRoles(roles); diff --git a/src/composables/useSession.js b/src/composables/useSession.js index 62cb8a28b..008337b02 100644 --- a/src/composables/useSession.js +++ b/src/composables/useSession.js @@ -1,5 +1,7 @@ import { useState } from './useState'; import { useRole } from './useRole'; +import { useUserConfig } from './useUserConfig'; + export function useSession() { function getToken() { @@ -36,11 +38,10 @@ export function useSession() { } async function login(token, keepLogin) { - const { fetch } = useRole(); - setToken({ token, keepLogin }); - await fetch(); + await useRole().fetch(); + await useUserConfig().fetch(); } function isLoggedIn() { diff --git a/src/composables/useUserConfig.js b/src/composables/useUserConfig.js index 0e4837aeb..767ffb54e 100644 --- a/src/composables/useUserConfig.js +++ b/src/composables/useUserConfig.js @@ -1,10 +1,14 @@ import axios from 'axios'; +import { useState } from './useState'; export function useUserConfig() { + const state = useState(); async function fetch() { const { data } = await axios.get('UserConfigs/getUserConfig'); - return data; + const user = state.getUser().value; + user.darkMode = data.darkMode; + state.setUser(user); } return {