mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-09 20:27:44 +00:00
docs: fix grammar and spelling mistakes (#2300)
* Next.js * ID * Punctuation, code * SQLite * Capitalization * Various corrections in "JWT"
This commit is contained in:
@@ -812,7 +812,7 @@ C0.7,239.6,62.1,0.5,62.2,0.4c0,0,54,13.8,119.9,30.8S302.1,62,302.2,62c0.2,0,0.2,
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Sqlite",
|
title: "SQLite",
|
||||||
href: "/docs/adapters/sqlite",
|
href: "/docs/adapters/sqlite",
|
||||||
icon: () => (
|
icon: () => (
|
||||||
<svg
|
<svg
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ type TechStackIconType = {
|
|||||||
};
|
};
|
||||||
export const techStackIcons: TechStackIconType = {
|
export const techStackIcons: TechStackIconType = {
|
||||||
nextJs: {
|
nextJs: {
|
||||||
name: "Nextjs",
|
name: "Next.js",
|
||||||
icon: <Icons.nextJS className="w-10 h-10" />,
|
icon: <Icons.nextJS className="w-10 h-10" />,
|
||||||
},
|
},
|
||||||
nuxt: {
|
nuxt: {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ description: Apple provider setup and usage.
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
On native iOS, it doesn't use the service id but the app id (bundle id) as client id, so if using the service id as clientId in `signIn.social` with idToken, it throws an error: `JWTClaimValidationFailed: unexpected "aud" claim value`. So you need to provide the `appBundleIdentifier` when you want to sign in with Apple using the ID Token.
|
On native iOS, it doesn't use the service ID but the app ID (bundle ID) as client ID, so if using the service ID as `clientId` in `signIn.social` with `idToken`, it throws an error: `JWTClaimValidationFailed: unexpected "aud" claim value`. So you need to provide the `appBundleIdentifier` when you want to sign in with Apple using the ID Token.
|
||||||
</Step>
|
</Step>
|
||||||
</Steps>
|
</Steps>
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ To sign in with Apple using the ID Token, you can use the `signIn.social` functi
|
|||||||
This is useful when you have the ID Token from Apple on the client-side and want to use it to sign in on the server.
|
This is useful when you have the ID Token from Apple on the client-side and want to use it to sign in on the server.
|
||||||
|
|
||||||
<Callout>
|
<Callout>
|
||||||
If id token is provided no redirection will happen, and the user will be signed in directly.
|
If ID token is provided no redirection will happen, and the user will be signed in directly.
|
||||||
</Callout>
|
</Callout>
|
||||||
|
|
||||||
```ts title="auth-client.ts"
|
```ts title="auth-client.ts"
|
||||||
@@ -125,4 +125,4 @@ await authClient.signIn.social({
|
|||||||
accessToken: // Access Token (optional)
|
accessToken: // Access Token (optional)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ To sign in with Facebook using the ID Token, you can use the `signIn.social` fun
|
|||||||
This is useful when you have the ID Token from Facebook on the client-side and want to use it to sign in on the server.
|
This is useful when you have the ID Token from Facebook on the client-side and want to use it to sign in on the server.
|
||||||
|
|
||||||
<Callout>
|
<Callout>
|
||||||
If id token is provided no redirection will happen, and the user will be signed in directly.
|
If ID token is provided no redirection will happen, and the user will be signed in directly.
|
||||||
</Callout>
|
</Callout>
|
||||||
|
|
||||||
For limited login, you need to pass `idToken.token`, for only `accessToken` you need to pass `idToken.accessToken` and `idToken.token` together because of (#1183)[https://github.com/better-auth/better-auth/issues/1183].
|
For limited login, you need to pass `idToken.token`, for only `accessToken` you need to pass `idToken.accessToken` and `idToken.token` together because of (#1183)[https://github.com/better-auth/better-auth/issues/1183].
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ To sign in with Google using the ID Token, you can use the `signIn.social` funct
|
|||||||
This is useful when you have the ID Token from Google on the client-side and want to use it to sign in on the server.
|
This is useful when you have the ID Token from Google on the client-side and want to use it to sign in on the server.
|
||||||
|
|
||||||
<Callout>
|
<Callout>
|
||||||
If id token is provided no redirection will happen, and the user will be signed in directly.
|
If ID token is provided no redirection will happen, and the user will be signed in directly.
|
||||||
</Callout>
|
</Callout>
|
||||||
|
|
||||||
```ts title="auth-client.ts"
|
```ts title="auth-client.ts"
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ import { authClient } from "@/lib/auth-client"; //import the auth client // [!co
|
|||||||
|
|
||||||
await authClient.signIn.social({
|
await authClient.signIn.social({
|
||||||
/**
|
/**
|
||||||
* The social provider id
|
* The social provider ID
|
||||||
* @example "github", "google", "apple"
|
* @example "github", "google", "apple"
|
||||||
*/
|
*/
|
||||||
provider: "github",
|
provider: "github",
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ Table Name: `session`
|
|||||||
{
|
{
|
||||||
name: "userId",
|
name: "userId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the user",
|
description: "The ID of the user",
|
||||||
isForeignKey: true,
|
isForeignKey: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -218,19 +218,19 @@ Table Name: `account`
|
|||||||
{
|
{
|
||||||
name: "userId",
|
name: "userId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the user",
|
description: "The ID of the user",
|
||||||
isForeignKey: true,
|
isForeignKey: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "accountId",
|
name: "accountId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description:
|
description:
|
||||||
"The id of the account as provided by the SSO or equal to userId for credential accounts",
|
"The ID of the account as provided by the SSO or equal to userId for credential accounts",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "providerId",
|
name: "providerId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the provider",
|
description: "The ID of the provider",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "accessToken",
|
name: "accessToken",
|
||||||
@@ -265,7 +265,7 @@ Table Name: `account`
|
|||||||
{
|
{
|
||||||
name: "idToken",
|
name: "idToken",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id token returned from the provider",
|
description: "The ID token returned from the provider",
|
||||||
isOptional: true,
|
isOptional: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ Better Auth manages session using a traditional cookie-based session management.
|
|||||||
The session table stores the session data. The session table has the following fields:
|
The session table stores the session data. The session table has the following fields:
|
||||||
|
|
||||||
- `id`: The session token. Which is also used as the session cookie.
|
- `id`: The session token. Which is also used as the session cookie.
|
||||||
- `userId`: The user id of the user.
|
- `userId`: The user ID of the user.
|
||||||
- `expiresAt`: The expiration date of the session.
|
- `expiresAt`: The expiration date of the session.
|
||||||
- `ipAddress`: The IP address of the user.
|
- `ipAddress`: The IP address of the user.
|
||||||
- `userAgent`: The user agent of the user. It stores the user agent header from the request.
|
- `userAgent`: The user agent of the user. It stores the user agent header from the request.
|
||||||
|
|
||||||
## Session Expiration
|
## Session Expiration
|
||||||
|
|
||||||
The session expires after 7 days by default. But whenever the session is used, and the `updateAge` is reached the session expiration is updated to the current time plus the `expiresIn` value.
|
The session expires after 7 days by default. But whenever the session is used and the `updateAge` is reached, the session expiration is updated to the current time plus the `expiresIn` value.
|
||||||
|
|
||||||
You can change both the `expiresIn` and `updateAge` values by passing the `session` object to the `auth` configuration.
|
You can change both the `expiresIn` and `updateAge` values by passing the `session` object to the `auth` configuration.
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export const myAdapter = (config: CustomAdapterConfig = {}) =>
|
|||||||
supportsJSON: false, // Whether the database supports JSON. (Default: false)
|
supportsJSON: false, // Whether the database supports JSON. (Default: false)
|
||||||
supportsDates: true, // Whether the database supports dates. (Default: true)
|
supportsDates: true, // Whether the database supports dates. (Default: true)
|
||||||
supportsBooleans: true, // Whether the database supports booleans. (Default: true)
|
supportsBooleans: true, // Whether the database supports booleans. (Default: true)
|
||||||
supportsNumericIds: true, // Whether the database supports auto-incrementing numeric ids. (Default: true)
|
supportsNumericIds: true, // Whether the database supports auto-incrementing numeric IDs. (Default: true)
|
||||||
},
|
},
|
||||||
// ...
|
// ...
|
||||||
});
|
});
|
||||||
@@ -156,7 +156,7 @@ The `create` method is used to create a new record in the database.
|
|||||||
|
|
||||||
<Callout>
|
<Callout>
|
||||||
Note:
|
Note:
|
||||||
If the user has enabled the `useNumberId` option, or if `generateId` is `false` in the user's Better-Auth config,
|
If the user has enabled the `useNumberId` option, or if `generateId` is `false` in the user's Better Auth config,
|
||||||
then it's expected that the `id` is provided in the `data` object. Otherwise, the `id` will be automatically generated.
|
then it's expected that the `id` is provided in the `data` object. Otherwise, the `id` will be automatically generated.
|
||||||
|
|
||||||
Additionally, it's possible to pass `forceAllowId` as a parameter to the `create` method, which allows `id` to be provided in the `data` object.
|
Additionally, it's possible to pass `forceAllowId` as a parameter to the `create` method, which allows `id` to be provided in the `data` object.
|
||||||
@@ -384,7 +384,7 @@ describe("My Adapter Tests", async () => {
|
|||||||
|
|
||||||
### Numeric ID tests
|
### Numeric ID tests
|
||||||
|
|
||||||
If your database supports numeric ids, then you should run this test as well:
|
If your database supports numeric IDs, then you should run this test as well:
|
||||||
|
|
||||||
```ts title="my-adapter.number-id.test.ts"
|
```ts title="my-adapter.number-id.test.ts"
|
||||||
import { expect, test, describe } from "vitest";
|
import { expect, test, describe } from "vitest";
|
||||||
@@ -430,7 +430,7 @@ The name of the adapter.
|
|||||||
|
|
||||||
### `supportsNumericIds`
|
### `supportsNumericIds`
|
||||||
|
|
||||||
Whether the database supports numeric ids. If this is set to `false` and the users config has enabled `useNumberId`, then we will throw an error.
|
Whether the database supports numeric IDs. If this is set to `false` and the user's config has enabled `useNumberId`, then we will throw an error.
|
||||||
|
|
||||||
### `supportsJSON`
|
### `supportsJSON`
|
||||||
|
|
||||||
@@ -480,11 +480,11 @@ const adapter = myAdapter({
|
|||||||
|
|
||||||
### `disableIdGeneration`
|
### `disableIdGeneration`
|
||||||
|
|
||||||
Whether to disable id generation. If this is set to `true`, then the user's `generateId` option will be ignored.
|
Whether to disable ID generation. If this is set to `true`, then the user's `generateId` option will be ignored.
|
||||||
|
|
||||||
### `customIdGenerator`
|
### `customIdGenerator`
|
||||||
|
|
||||||
If your database only supports a specific custom id generation, then you can use this option to generate your own IDs.
|
If your database only supports a specific custom ID generation, then you can use this option to generate your own IDs.
|
||||||
|
|
||||||
### `mapKeysTransformInput`
|
### `mapKeysTransformInput`
|
||||||
|
|
||||||
@@ -546,7 +546,7 @@ The `customTransformInput` function runs at every key in the data object of a gi
|
|||||||
```ts title="Example"
|
```ts title="Example"
|
||||||
customTransformInput: ({ field, data }) => {
|
customTransformInput: ({ field, data }) => {
|
||||||
if (field === "id") {
|
if (field === "id") {
|
||||||
return "123"; // Force the id to be "123"
|
return "123"; // Force the ID to be "123"
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ export default function App() {
|
|||||||
|
|
||||||
#### IdToken Sign-In
|
#### IdToken Sign-In
|
||||||
|
|
||||||
If you want to make provider request on the mobile device and then verify the id token on the server, you can use the `authClient.signIn.social` method with the `idToken` option.
|
If you want to make provider request on the mobile device and then verify the ID token on the server, you can use the `authClient.signIn.social` method with the `idToken` option.
|
||||||
|
|
||||||
```tsx title="app/social-sign-in.tsx"
|
```tsx title="app/social-sign-in.tsx"
|
||||||
import { Button } from "react-native";
|
import { Button } from "react-native";
|
||||||
@@ -287,7 +287,7 @@ export default function App() {
|
|||||||
await authClient.signIn.social({
|
await authClient.signIn.social({
|
||||||
provider: "google", // only google, apple and facebook are supported for idToken sign-in
|
provider: "google", // only google, apple and facebook are supported for idToken sign-in
|
||||||
idToken: {
|
idToken: {
|
||||||
token: "...", // id token from provider
|
token: "...", // ID token from provider
|
||||||
nonce: "...", // nonce from provider (optional)
|
nonce: "...", // nonce from provider (optional)
|
||||||
}
|
}
|
||||||
callbackURL: "/dashboard" // this will be converted to a deep link (eg. `myapp://dashboard`) on native
|
callbackURL: "/dashboard" // this will be converted to a deep link (eg. `myapp://dashboard`) on native
|
||||||
|
|||||||
@@ -364,8 +364,8 @@ Table: `twoFactor`
|
|||||||
|
|
||||||
<DatabaseTable
|
<DatabaseTable
|
||||||
fields={[
|
fields={[
|
||||||
{ name: "id", type: "string", description: "The id of the two factor authentication.", isPrimaryKey: true },
|
{ name: "id", type: "string", description: "The ID of the two factor authentication.", isPrimaryKey: true },
|
||||||
{ name: "userId", type: "string", description: "The id of the user", isForeignKey: true },
|
{ name: "userId", type: "string", description: "The ID of the user", isForeignKey: true },
|
||||||
{ name: "secret", type: "string", description: "The secret used to generate the TOTP code.", isOptional: true },
|
{ name: "secret", type: "string", description: "The secret used to generate the TOTP code.", isOptional: true },
|
||||||
{ name: "backupCodes", type: "string", description: "The backup codes used to recover access to the account if the user loses access to their phone or email.", isOptional: true },
|
{ name: "backupCodes", type: "string", description: "The backup codes used to recover access to the account if the user loses access to their phone or email.", isOptional: true },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ You can view the list of API Key plugin options [here](/docs/plugins/api-key#api
|
|||||||
rateLimitTimeWindow: 1000 * 60 * 60 * 24, // everyday
|
rateLimitTimeWindow: 1000 * 60 * 60 * 24, // everyday
|
||||||
rateLimitMax: 100, // every day, they can use up to 100 requests
|
rateLimitMax: 100, // every day, they can use up to 100 requests
|
||||||
rateLimitEnabled: true,
|
rateLimitEnabled: true,
|
||||||
userId: user.id, // the user id to create the API key for
|
userId: user.id, // the user ID to create the API key for
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
@@ -203,7 +203,7 @@ const key = await auth.api.getApiKey({
|
|||||||
|
|
||||||
#### Properties
|
#### Properties
|
||||||
|
|
||||||
- `keyId`: The API Key id to get information on.
|
- `keyId`: The API key ID to get information on.
|
||||||
|
|
||||||
#### Result
|
#### Result
|
||||||
|
|
||||||
@@ -255,10 +255,10 @@ type Result = Omit<ApiKey, "key">;
|
|||||||
|
|
||||||
#### Properties
|
#### Properties
|
||||||
|
|
||||||
<DividerText>Client</DividerText>- `keyId`: The API key Id to update on. -
|
<DividerText>Client</DividerText>- `keyId`: The API key ID to update on. -
|
||||||
`name`?: Update the key name.
|
`name`?: Update the key name.
|
||||||
|
|
||||||
<DividerText>Server Only</DividerText>- `userId`?: Update the user id who owns
|
<DividerText>Server Only</DividerText>- `userId`?: Update the user ID who owns
|
||||||
this key. - `name`?: Update the key name. - `enabled`?: Update whether the API
|
this key. - `name`?: Update the key name. - `enabled`?: Update whether the API
|
||||||
key is enabled or not. - `remaining`?: Update the remaining count. -
|
key is enabled or not. - `remaining`?: Update the remaining count. -
|
||||||
`refillAmount`?: Update the amount to refill the `remaining` count every
|
`refillAmount`?: Update the amount to refill the `remaining` count every
|
||||||
@@ -301,7 +301,7 @@ Otherwise, you'll receive the API Key details, except for the `key` value itself
|
|||||||
|
|
||||||
#### Properties
|
#### Properties
|
||||||
|
|
||||||
- `keyId`: The API Key id to delete.
|
- `keyId`: The API key ID to delete.
|
||||||
|
|
||||||
#### Result
|
#### Result
|
||||||
|
|
||||||
@@ -757,7 +757,7 @@ Table: `apiKey`
|
|||||||
{
|
{
|
||||||
name: "userId",
|
name: "userId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the user who created the API key.",
|
description: "The ID of the user who created the API key.",
|
||||||
isForeignKey: true,
|
isForeignKey: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ description: Authenticate users with JWT tokens in services that can't use the s
|
|||||||
The JWT plugin provides endpoints to retrieve a JWT token and a JWKS endpoint to verify the token.
|
The JWT plugin provides endpoints to retrieve a JWT token and a JWKS endpoint to verify the token.
|
||||||
|
|
||||||
<Callout type="info">
|
<Callout type="info">
|
||||||
This plugin is not meant as a replacement for the session. It's meant to be used for services that requires JWT tokens.
|
This plugin is not meant as a replacement for the session. It's meant to be used for services that require JWT tokens.
|
||||||
</Callout>
|
</Callout>
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@@ -58,7 +58,7 @@ Once you've installed the plugin, you can start using the JWT & JWKS plugin to g
|
|||||||
|
|
||||||
1. Using your session token
|
1. Using your session token
|
||||||
|
|
||||||
To get the token, call the `/token`, this will return the following:
|
To get the token, call the `/token` endpoint. This will return the following:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ To get the token, call the `/token`, this will return the following:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure to include the token in the Authorization header of your requests. And `bearer` plugin is added in your auth configuration.
|
Make sure to include the token in the `Authorization` header of your requests and the `bearer` plugin is added in your auth configuration.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
await fetch("/api/auth/token", {
|
await fetch("/api/auth/token", {
|
||||||
@@ -78,7 +78,7 @@ await fetch("/api/auth/token", {
|
|||||||
|
|
||||||
2. From `set-auth-jwt` header
|
2. From `set-auth-jwt` header
|
||||||
|
|
||||||
When you call `getSession` method a jwt is returned in `set-auth-jwt` header. Which you can use to send to your services directly.
|
When you call `getSession` method, a JWT is returned in the `set-auth-jwt` header, which you can use to send to your services directly.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
await authClient.getSession({
|
await authClient.getSession({
|
||||||
@@ -92,11 +92,11 @@ await authClient.getSession({
|
|||||||
|
|
||||||
### Verifying the token
|
### Verifying the token
|
||||||
The token can be verified in your own service, without the need for an additional verify call or database check.
|
The token can be verified in your own service, without the need for an additional verify call or database check.
|
||||||
For this JWKS is used, the public key can be fetched from the `/api/auth/jwks` endpoint.
|
For this JWKS is used. The public key can be fetched from the `/api/auth/jwks` endpoint.
|
||||||
|
|
||||||
Since this key is not subject to a frequent change, it can be cached indefinitely.
|
Since this key is not subject to frequent changes, it can be cached indefinitely.
|
||||||
The Key ID (kid) that was used to sign a JWT is included in the header of the token.
|
The key ID (`kid`) that was used to sign a JWT is included in the header of the token.
|
||||||
In the case a JWT with a different kid is received it is recommended to fetch the JWKS again.
|
In case a JWT with a different `kid` is received, it is recommended to fetch the JWKS again.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -211,7 +211,7 @@ Table Name: `jwks`
|
|||||||
|
|
||||||
### Algorithm of the Key Pair
|
### Algorithm of the Key Pair
|
||||||
|
|
||||||
The algorithm used for the generation of the keypair. The default is **EdDSA** with the **Ed25519** curve. Below are the available options:
|
The algorithm used for the generation of the key pair. The default is **EdDSA** with the **Ed25519** curve. Below are the available options:
|
||||||
|
|
||||||
```ts title="auth.ts"
|
```ts title="auth.ts"
|
||||||
jwt({
|
jwt({
|
||||||
@@ -285,7 +285,7 @@ jwt({
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Modify Issuer, Audience, Subject or Expiration time
|
### Modify Issuer, Audience, Subject or Expiration time
|
||||||
If none is given, the BASE_URL is used as the issuer and the audience is set to the BASE_URL. The expiration time is set to 15 minutes.
|
If none is given, the `BASE_URL` is used as the issuer and the audience is set to the `BASE_URL`. The expiration time is set to 15 minutes.
|
||||||
|
|
||||||
```ts title="auth.ts"
|
```ts title="auth.ts"
|
||||||
jwt({
|
jwt({
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ To retrieve the active organization for the user, you can call the `useActiveOrg
|
|||||||
|
|
||||||
To get the full details of an organization, you can use the `getFullOrganization` function provided by the client. The function takes an object with the following properties:
|
To get the full details of an organization, you can use the `getFullOrganization` function provided by the client. The function takes an object with the following properties:
|
||||||
|
|
||||||
- `organizationId`: The id of the organization. (Optional) – By default, it will use the active organization.
|
- `organizationId`: The ID of the organization. (Optional) – By default, it will use the active organization.
|
||||||
- `organizationSlug`: The slug of the organization. (Optional) – To get the organization by slug.
|
- `organizationSlug`: The slug of the organization. (Optional) – To get the organization by slug.
|
||||||
|
|
||||||
<Tabs items={["client", "server"]}>
|
<Tabs items={["client", "server"]}>
|
||||||
@@ -502,7 +502,7 @@ To invite users to an organization, you can use the `invite` function provided b
|
|||||||
|
|
||||||
- `email`: The email address of the user.
|
- `email`: The email address of the user.
|
||||||
- `role`: The role of the user in the organization. It can be `admin`, `member`, or `guest`.
|
- `role`: The role of the user in the organization. It can be `admin`, `member`, or `guest`.
|
||||||
- `organizationId`: The id of the organization. this is optional by default it will use the active organization. (Optional)
|
- `organizationId`: The ID of the organization. this is optional by default it will use the active organization. (Optional)
|
||||||
|
|
||||||
```ts title="invitation.ts"
|
```ts title="invitation.ts"
|
||||||
await authClient.organization.inviteMember({
|
await authClient.organization.inviteMember({
|
||||||
@@ -531,7 +531,7 @@ await authClient.organization.acceptInvitation({
|
|||||||
|
|
||||||
### Update Invitation Status
|
### Update Invitation Status
|
||||||
|
|
||||||
To update the status of invitation you can use the `acceptInvitation`, `cancelInvitation`, `rejectInvitation` functions provided by the client. The functions take the invitation id as an argument.
|
To update the status of invitation you can use the `acceptInvitation`, `cancelInvitation`, `rejectInvitation` functions provided by the client. The functions take the invitation ID as an argument.
|
||||||
|
|
||||||
```ts title="auth-client.ts"
|
```ts title="auth-client.ts"
|
||||||
//cancel invitation
|
//cancel invitation
|
||||||
@@ -548,7 +548,7 @@ await authClient.organization.rejectInvitation({
|
|||||||
|
|
||||||
### Get Invitation
|
### Get Invitation
|
||||||
|
|
||||||
To get an invitation you can use the `getInvitation` function provided by the client. You need to provide the invitation id as a query parameter.
|
To get an invitation you can use the `getInvitation` function provided by the client. You need to provide the invitation ID as a query parameter.
|
||||||
|
|
||||||
```ts title="auth-client.ts"
|
```ts title="auth-client.ts"
|
||||||
await authClient.organization.getInvitation({
|
await authClient.organization.getInvitation({
|
||||||
@@ -1019,7 +1019,7 @@ When teams are enabled, a new `team` table is added with the following structure
|
|||||||
{
|
{
|
||||||
name: "organizationId",
|
name: "organizationId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the organization",
|
description: "The ID of the organization",
|
||||||
isForeignKey: true
|
isForeignKey: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1096,13 +1096,13 @@ Table Name: `member`
|
|||||||
{
|
{
|
||||||
name: "userId",
|
name: "userId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the user",
|
description: "The ID of the user",
|
||||||
isForeignKey: true
|
isForeignKey: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "organizationId",
|
name: "organizationId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the organization",
|
description: "The ID of the organization",
|
||||||
isForeignKey: true
|
isForeignKey: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1138,13 +1138,13 @@ Table Name: `invitation`
|
|||||||
{
|
{
|
||||||
name: "inviterId",
|
name: "inviterId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the inviter",
|
description: "The ID of the inviter",
|
||||||
isForeignKey: true
|
isForeignKey: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "organizationId",
|
name: "organizationId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the organization",
|
description: "The ID of the organization",
|
||||||
isForeignKey: true
|
isForeignKey: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1174,14 +1174,14 @@ Table Name: `invitation`
|
|||||||
|
|
||||||
Table Name: `session`
|
Table Name: `session`
|
||||||
|
|
||||||
You need to add one more field to the session table to store the active organization id.
|
You need to add one more field to the session table to store the active organization ID.
|
||||||
|
|
||||||
<DatabaseTable
|
<DatabaseTable
|
||||||
fields={[
|
fields={[
|
||||||
{
|
{
|
||||||
name: "activeOrganizationId",
|
name: "activeOrganizationId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the active organization",
|
description: "The ID of the active organization",
|
||||||
isOptional: true
|
isOptional: true
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
@@ -1207,7 +1207,7 @@ Table Name: `team`
|
|||||||
{
|
{
|
||||||
name: "organizationId",
|
name: "organizationId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the organization",
|
description: "The ID of the organization",
|
||||||
isForeignKey: true
|
isForeignKey: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1231,7 +1231,7 @@ Table Name: `team`
|
|||||||
{
|
{
|
||||||
name: "teamId",
|
name: "teamId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the team",
|
description: "The ID of the team",
|
||||||
isOptional: true
|
isOptional: true
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
@@ -1244,7 +1244,7 @@ Table Name: `team`
|
|||||||
{
|
{
|
||||||
name: "teamId",
|
name: "teamId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the team",
|
description: "The ID of the team",
|
||||||
isOptional: true
|
isOptional: true
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ Table Name: `passkey`
|
|||||||
{
|
{
|
||||||
name: "userId",
|
name: "userId",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The id of the user",
|
description: "The ID of the user",
|
||||||
isForeignKey: true
|
isForeignKey: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -215,8 +215,8 @@ The plugin requires additional fields in the `ssoProvider` table to store the pr
|
|||||||
{ name: "issuer", type: "string", description: "The issuer identifier", isRequired: true },
|
{ name: "issuer", type: "string", description: "The issuer identifier", isRequired: true },
|
||||||
{ name: "domain", type: "string", description: "The domain of the provider", isRequired: true },
|
{ name: "domain", type: "string", description: "The domain of the provider", isRequired: true },
|
||||||
{ name: "oidcConfig", type: "string", description: "The OIDC configuration", isRequired: false },
|
{ name: "oidcConfig", type: "string", description: "The OIDC configuration", isRequired: false },
|
||||||
{ name: "userId", type: "string", description: "The user id", isRequired: true, references: { model: "user", field: "id" } },
|
{ name: "userId", type: "string", description: "The user ID", isRequired: true, references: { model: "user", field: "id" } },
|
||||||
{ name: "providerId", type: "string", description: "The provider id. Used to identify a provider and to generate a redirect URL.", isRequired: true, isUnique: true },
|
{ name: "providerId", type: "string", description: "The provider ID. Used to identify a provider and to generate a redirect URL.", isRequired: true, isUnique: true },
|
||||||
{ name: "organizationId", type: "string", description: "The organization Id. If provider is linked to an organization.", isRequired: false },
|
{ name: "organizationId", type: "string", description: "The organization Id. If provider is linked to an organization.", isRequired: false },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -164,8 +164,8 @@ subscription: {
|
|||||||
plans: [
|
plans: [
|
||||||
{
|
{
|
||||||
name: "basic", // the name of the plan, it'll be automatically lower cased when stored in the database
|
name: "basic", // the name of the plan, it'll be automatically lower cased when stored in the database
|
||||||
priceId: "price_1234567890", // the price id from stripe
|
priceId: "price_1234567890", // the price ID from stripe
|
||||||
annualDiscountPriceId: "price_1234567890", // (optional) the price id for annual billing with a discount
|
annualDiscountPriceId: "price_1234567890", // (optional) the price ID for annual billing with a discount
|
||||||
limits: {
|
limits: {
|
||||||
projects: 5,
|
projects: 5,
|
||||||
storage: 10
|
storage: 10
|
||||||
@@ -211,7 +211,7 @@ await client.subscription.upgrade({
|
|||||||
successUrl: "/dashboard",
|
successUrl: "/dashboard",
|
||||||
cancelUrl: "/pricing",
|
cancelUrl: "/pricing",
|
||||||
annual: true, // Optional: upgrade to an annual plan
|
annual: true, // Optional: upgrade to an annual plan
|
||||||
referenceId: "org_123" // Optional: defaults to the current logged in user id
|
referenceId: "org_123" // Optional: defaults to the current logged in user ID
|
||||||
seats: 5 // Optional: for team plans
|
seats: 5 // Optional: for team plans
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -420,7 +420,7 @@ export const auth = betterAuth({
|
|||||||
database: {
|
database: {
|
||||||
// If your DB is using auto-incrementing IDs, set this to true.
|
// If your DB is using auto-incrementing IDs, set this to true.
|
||||||
useNumberId: false,
|
useNumberId: false,
|
||||||
// Use your own custom id generator, or disable generating IDs as a whole.
|
// Use your own custom ID generator, or disable generating IDs as a whole.
|
||||||
generateId: (((options: {
|
generateId: (((options: {
|
||||||
model: LiteralUnion<Models, string>;
|
model: LiteralUnion<Models, string>;
|
||||||
size?: number;
|
size?: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user