Replies: 3 comments 2 replies
-
Hey @ranseur92! Better refresh CookieIn #131 we talked about adding the IPV4-FirstThis is not a problem which is caused by If a recommendation from the Nuxt team is in favor of implementing this fix, we can talk about it. But for now, we don't want to that. But we can make an Information in the documentation for all who gets the problem. Expiration composablesThis is a great idea and we will implement this soon, with this composables the handling of expires date will be better. Thinking about adding this to the const expires_in = computed(() => Math.max(0, (expires().value ?? 0) - new Date().getTime()));
const expired = computed(() => !token().value || expires_in.value == 0); Auto-Refresh TokensAdding this to a plugin would be a great idea, we have to check in how this causes maybe a breaking change and if they are other alternatives. @casualmatt Thought about adding this to the But maybe a plugin which uses the expiration date would be better. Thank you @ranseur92 for this RFC 💚 |
Beta Was this translation helpful? Give feedback.
-
if it's ok with @casualmatt and @Intevel I have already develop all features of this RFC. I can port them to this library except the ipv4-first, and submit a PR? Everything will be opt-in based off of config, so no breaking changes. |
Beta Was this translation helpful? Give feedback.
-
Closed with #142 |
Beta Was this translation helpful? Give feedback.
-
Originally, I built my own port of Directus SDK to add features i wanted, But I figured I'd might as well contribute to this 1to make it better for everyone else.
Better refresh Cookie
Specifying the length of the refresh token in the module config/runtime config, we can use that to ensure the cookie lasts as long as it's intended too.
const cookie = useCookie<string | null>('directus_refresh_token', { maxAge: config.public.directus.refresh_token_expires })
IPV4-First
If the users directus url contains localhost, call
add expiration composables to useTokens
Would be nice and could aid in benefiting other features of the module, such as when passing the auth token,
Auto refresh tokens
When using directus, it would be nice if we had an option to refresh tokens before requests if it's missing or expired, and a refresh token exists.
and also, checking the refresh token on app/page load could be nice for OAuth implementations.
I would suggest also editing fetch-user to use the above format, that way it's called when needed.
Beta Was this translation helpful? Give feedback.
All reactions