Skip to content

Commit

Permalink
✨ refresh mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
brano-hozza committed Mar 25, 2024
1 parent 29247b5 commit feb2536
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions components/layout/NavigationComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,19 @@ const accountStore = useAccountStore();
const account = computed(() => accountStore.account);
onMounted(async () => {
const accounts = await $web3?.eth.getAccounts();
accountStore.setAccount(accounts?.[0] ?? null);
if (account.value) {
logger.info('Account connected:', account);
}
logger.info('Refresh tokens');
const { accessToken, refreshToken } = await $fetch('/api/auth/refresh', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ jwt: accountStore.accessToken, refreshToken: accountStore.refreshToken }),
});
accountStore.setToken(accessToken, refreshToken);
});
const signMessage = async (message: string): Promise<string> => {
Expand Down

0 comments on commit feb2536

Please sign in to comment.