Skip to content

Commit

Permalink
optimize tokenRefresh for production
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan committed Mar 18, 2023
1 parent fb36edb commit c3ee966
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
20 changes: 10 additions & 10 deletions src/stores/auth.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 1 addition & 3 deletions src/stores/gates.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/views/tools/SpeedChecker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
name="house_number_extension"
class="form-control"
:placeholder="$t('speedchecker.placeholder.house_number_extension')"
type="number"
type="text"
/>
</b-input-group>
</b-card-body>
Expand All @@ -50,7 +50,7 @@
</CardHeader>
</template>
<b-tabs card>
<b-tab :title="$t('speedchecker.fiber_info.title')" active v-if="this.responseData.fixed_info.fiber_access">
<b-tab :title="$t('speedchecker.fiber_info.title')" active>
<b-card-text>
<table class="table" style="width: 550px">
<tr>
Expand Down

0 comments on commit c3ee966

Please sign in to comment.