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

🔄 synced file(s) with sidebase/nuxt-auth #181

Merged
merged 1 commit into from
May 16, 2024
Merged
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
66 changes: 50 additions & 16 deletions content/2.nuxt-auth/2.configuration/2.nuxt-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,31 @@ type ProviderLocal = {
*/
cookieDomain?: string;
},
/**
* Define an interface for the session data object that `nuxt-auth` expects to receive from the `getSession` endpoint.
*
* @default { id: 'string | number' }
* @example { id: 'string', name: 'string', email: 'string' }
* @advanced_array_example { id: 'string', email: 'string', name: 'string', role: 'admin | guest | account', subscriptions: "{ id: number, status: 'ACTIVE' | 'INACTIVE' }[]" }
/*
* Settings for the session-data that `nuxt-auth` receives from the `getSession` endpoint.
*/
sessionDataType?: SessionDataObject,
session?: {
/**
* Define an interface for the session data object that `nuxt-auth` expects to receive from the `getSession` endpoint.
*
* @default { id: 'string | number' }
* @example { id: 'string', name: 'string', email: 'string' }
* @advanced_array_example { id: 'string', email: 'string', name: 'string', role: 'admin | guest | account', subscriptions: "{ id: number, status: 'ACTIVE' | 'INACTIVE' }[]" }
*/
dataType?: SessionDataObject;
/**
* How to extract the session-data from the session response.
*
* E.g., setting this to `/data/user` and returning an object like `{ data: { user: { id:number, name: string } }, status: 'ok' }` from the `getSession` endpoint will
* storing the 'User' object typed as the type created via the 'dataType' prop.
*
* This follows the JSON Pointer standard, see it's RFC6901 here: https://www.rfc-editor.org/rfc/rfc6901
*
* @default / Access the root of the session response object
* @example /data/user Access the `data/user` property of the session response object
*/
dataResponsePointer?: string;
}
}

```
Expand Down Expand Up @@ -406,7 +423,7 @@ type ProviderRefresh = {
* @default '/refreshToken' Access the `refreshToken` property of the sign-in response object
* @example / Access the root of the sign-in response object, useful when your endpoint returns a plain, non-object string as the refreshToken
*/
signInResponseRefreshTokenPointer?: string
signInResponseRefreshTokenPointer?: string,
/**
* How to do a fetch for the refresh token.
*
Expand Down Expand Up @@ -445,14 +462,31 @@ type ProviderRefresh = {
*/
cookieDomain?: string;
},
/**
* Define an interface for the session data object that `nuxt-auth` expects to receive from the `getSession` endpoint.
*
* @default { id: 'string | number' }
* @example { id: 'string', name: 'string', email: 'string' }
* @advanced_array_example { id: 'string', email: 'string', name: 'string', role: 'admin | guest | account', subscriptions: "{ id: number, status: 'ACTIVE' | 'INACTIVE' }[]" }
/*
* Settings for the session-data that `nuxt-auth` receives from the `getSession` endpoint.
*/
sessionDataType?: SessionDataObject,
session?: {
/**
* Define an interface for the session data object that `nuxt-auth` expects to receive from the `getSession` endpoint.
*
* @default { id: 'string | number' }
* @example { id: 'string', name: 'string', email: 'string' }
* @advanced_array_example { id: 'string', email: 'string', name: 'string', role: 'admin | guest | account', subscriptions: "{ id: number, status: 'ACTIVE' | 'INACTIVE' }[]" }
*/
dataType?: SessionDataObject;
/**
* How to extract the session-data from the session response.
*
* E.g., setting this to `/data/user` and returning an object like `{ data: { user: { id:number, name: string } }, status: 'ok' }` from the `getSession` endpoint will
* storing the 'User' object typed as the type created via the 'dataType' prop.
*
* This follows the JSON Pointer standard, see it's RFC6901 here: https://www.rfc-editor.org/rfc/rfc6901
*
* @default / Access the root of the session response object
* @example /data/user Access the `data/user` property of the session response object
*/
dataResponsePointer?: string;
}
}
```
```ts [SessionConfig]
Expand All @@ -471,7 +505,7 @@ type SessionConfig = {
* @default false
*
*/
enableRefreshPeriodically: number | boolean
enableRefreshPeriodically: number | boolean,
/**
* Whether to refresh the session every time the browser window is refocused.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ inferface SessionData {
id: string | number
}

// Option B: You configured `auth.provider.sessionDataType` to something like ` { id: 'string', email: 'string', name: 'string', role: 'admin | guest | account' }`
// Option B: You configured `auth.provider.session.dataType` to something like ` { id: 'string', email: 'string', name: 'string', role: 'admin | guest | account' }`
inferface SessionData {
id: string
email: string
Expand All @@ -196,7 +196,7 @@ inferface SessionData {
```
::

### About `auth.provider.sessionDataType`
### About `auth.provider.session.dataType`

This is a configuration option available to dynamically type the `SessionData` that the `local` provider will return when accessing `data.value`. Read more about this in the [nuxt.config.ts configuration documentation](/nuxt-auth/v0.6/configuration/nuxt-config) of the `local` provider.

Expand Down
Loading