diff --git a/src/App.vue b/src/App.vue index 274bee0..08f85c2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -113,10 +113,10 @@ export default { setup() { const auth = useAuthStore(); auth.tokenRefresh(); - + /* Set roles after page load */ const gate = useGatesStore(); - gate.setRoles() + gate.setRoles(); }, data() { diff --git a/src/stores/auth.store.js b/src/stores/auth.store.js index 5e860ef..6240bf8 100644 --- a/src/stores/auth.store.js +++ b/src/stores/auth.store.js @@ -53,21 +53,21 @@ export const useAuthStore = defineStore({ }, async tokenRefresh() { - /* Refresh token */ if (this.token) { - const result = await db.collection('users').authRefresh(); - if(!result) { - this.$patch({ - token: null, - user: null - }); + const auth = await db.collection('users').authRefresh({}, { + expand: 'roles' + }); - this.router.push('/'); + if(!auth) { + this.logout(); } - return result; + + this.$patch({ + token: auth.token, + user: auth.record + }) } - return false; }, /* Create user with random password without verified status */ diff --git a/src/stores/gates.store.js b/src/stores/gates.store.js index e5e1200..9b929a7 100644 --- a/src/stores/gates.store.js +++ b/src/stores/gates.store.js @@ -9,12 +9,10 @@ export const useGatesStore = defineStore("gates", () => { const setRoles = () => { - const auth = useAuthStore(); - console.log(auth) const role = db.authStore.model.expand.roles.map(role => { return role.name }) - console.log(role) + $zo.setRoles([...role]); } diff --git a/src/views/tools/SpeedChecker.vue b/src/views/tools/SpeedChecker.vue index 33df548..c1bd612 100644 --- a/src/views/tools/SpeedChecker.vue +++ b/src/views/tools/SpeedChecker.vue @@ -32,7 +32,7 @@ name="house_number_extension" class="form-control" :placeholder="$t('speedchecker.placeholder.house_number_extension')" - type="number" + type="text" /> @@ -50,7 +50,7 @@ - +