Skip to content

Commit

Permalink
Merge pull request #182 from Sandros94/main
Browse files Browse the repository at this point in the history
  • Loading branch information
Intevel committed Aug 10, 2023
2 parents e7355bf + 3dd4783 commit e5ba1c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions docs/content/1.getting-started/2.options.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ The function that get called if the `autoRefresh` fail

## `cookieMaxAge`

- Default: `604800`
- Default: `604800000`

Need to be the same as specified in your directus config; this is the max amount of milliseconds that your refresh cookie will be kept in the browser.
Need to be the same as specified in your directus env config ([defaults to `7d`](https://docs.directus.io/self-hosted/config-options.html#security)); this is the max amount of milliseconds that your refresh cookie will be kept in the browser. This value could be configured in a more *human readable* way as `7 * 24 * 60 * 60 * 1000`.

Auto refesh tokens

Expand Down
23 changes: 12 additions & 11 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface ModuleOptions {
/**
* Token Cookie Name
* @type string
@ default 'directus_token'
* @ default 'directus_token'
*/
cookieNameToken?: string;
/**
Expand All @@ -60,18 +60,18 @@ export interface ModuleOptions {
cookieNameRefreshToken?: string;

/**
* The max age for auth cookies in seconds.
* The max age for auth cookies in milliseconds.
* This should match your directus env key REFRESH_TOKEN_TTL
* @type string
* @default 604800
* @default 604800000
*/
cookieMaxAge?: number;

/**
* The max age for auth cookies in seconds.
* The max age for auth cookies in milliseconds.
* This should match your directus env key REFRESH_TOKEN_TTL
* @type string
* @default 604800
* @default 604800000
*/
maxAgeRefreshToken?: number;

Expand Down Expand Up @@ -108,12 +108,12 @@ export default defineNuxtModule<ModuleOptions>({
cookieNameRefreshToken: 'directus_refresh_token',

// Nuxt Cookies Docs @ https://nuxt.com/docs/api/composables/use-cookie
cookieMaxAge: 604800,
cookieMaxAge: 604800000,
cookieSameSite: 'lax',
cookieSecure: false
},
setup(options, nuxt) {
nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
setup (options, nuxt) {
nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {}
nuxt.options.runtimeConfig.public.directus = defu(
nuxt.options.runtimeConfig.public.directus,
{
Expand All @@ -130,17 +130,18 @@ export default defineNuxtModule<ModuleOptions>({
cookieSameSite: options.cookieSameSite,
cookieSecure: options.cookieSecure
})

const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))
nuxt.options.build.transpile.push(runtimeDir)

addPlugin(resolve(runtimeDir, 'plugin'))
addImportsDir(resolve(runtimeDir, 'composables'))
if (options.maxAgeRefreshToken) {
// eslint-disable-next-line no-console
console.warn(
'maxAgeRefreshToken is deprecated, please use cookieMaxAge instead'
);
}
)
}

if (options.devtools) {
const adminUrl = joinURL(nuxt.options.runtimeConfig.public.directus.url, '/admin/')
Expand Down

1 comment on commit e5ba1c1

@vercel
Copy link

@vercel vercel bot commented on e5ba1c1 Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nuxt-directus – ./

nuxt-directus-intevel.vercel.app
nuxt-directus-docs.vercel.app
nuxt-directus-git-main-intevel.vercel.app

Please sign in to comment.