Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/adding refresh token body key to refresh provider #690

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/content/2.configuration/2.nuxt-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,12 @@ type ProviderRefresh = {
* @example 60 * 60 * 24
*/
maxAgeInSeconds?: number,
/**
* Refresh request body key
*
* @default refreshToken
*/
requestbodyKey: string
},
/**
* Define an interface for the session data object that `nuxt-auth` expects to receive from the `getSession` endpoint.
Expand Down
3 changes: 2 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@
},
refreshToken: {
signInResponseRefreshTokenPointer: '/refreshToken',
maxAgeInSeconds: 60 * 60 * 24 * 7, // 7 days,
cookieName: 'auth.refresh-token',
maxAgeInSeconds: 60 * 60 * 24 * 7 // 7 days
requestbodyKey : "refreshToken"

Check failure on line 88 in src/module.ts

View workflow job for this annotation

GitHub Actions / test-module

Extra space after key 'requestbodyKey'

Check failure on line 88 in src/module.ts

View workflow job for this annotation

GitHub Actions / test-module

Strings must use singlequote
},
sessionDataType: { id: 'string | number' }
},
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/composables/refresh/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const refresh = async () => {
method,
headers,
body: {
refreshToken: refreshToken.value
[config.refreshToken.requestbodyKey]: refreshToken.value
}
})

Expand Down
6 changes: 6 additions & 0 deletions src/runtime/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@
* Note: Your backend may reject / expire the token earlier / differently.
*/
maxAgeInSeconds?: number;
/**
* Refresh request body key

Check failure on line 234 in src/runtime/types.ts

View workflow job for this annotation

GitHub Actions / test-module

Trailing spaces not allowed
*

Check failure on line 235 in src/runtime/types.ts

View workflow job for this annotation

GitHub Actions / test-module

Trailing spaces not allowed
* @default refreshToken
*/
requestbodyKey: string
};
};

Expand Down
Loading