fix: get user role before all requests (#393)

This commit is contained in:
Dream Hunter
2024-08-11 19:29:49 +08:00
committed by GitHub
parent bf1243f4c4
commit c733d3bf4d
4 changed files with 15 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ const message = useMessage()
const {
toggleDark, isDark, isTelegram, showAdminPage,
showAuth, auth, loading, openSettings
showAuth, auth, loading, openSettings, userSettings
} = useGlobalState()
const route = useRoute()
const router = useRouter()
@@ -224,11 +224,8 @@ const logoClick = async () => {
onMounted(async () => {
await api.getOpenSettings(message);
try {
await api.getUserSettings(message);
} catch (error) {
console.error(error);
}
// make sure user_id is fetched
if (!userSettings.value.user_id) await api.getUserSettings(message);
});
</script>