mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-09 04:19:26 +00:00
docs: imprvoe account linking docs
This commit is contained in:
@@ -38,6 +38,11 @@ export const auth = betterAuth({
|
|||||||
},
|
},
|
||||||
sendOnSignUp: true,
|
sendOnSignUp: true,
|
||||||
},
|
},
|
||||||
|
account: {
|
||||||
|
accountLinking: {
|
||||||
|
trustedProviders: ["google", "github"],
|
||||||
|
},
|
||||||
|
},
|
||||||
emailAndPassword: {
|
emailAndPassword: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
async sendResetPassword(user, url) {
|
async sendResetPassword(user, url) {
|
||||||
|
|||||||
@@ -122,23 +122,13 @@ The account table stores the authentication data of the user. The account table
|
|||||||
|
|
||||||
### Account linking
|
### Account linking
|
||||||
|
|
||||||
Account linking allows users to connect multiple authentication methods to a single account. Better Auth supports linking social sign-on or OAuth providers to an existing account if the provider returns a verified email. If the email isn't verified, the account can't be linked.
|
Account linking allows users to connect multiple authentication methods to a single account. Better Auth supports linking social sign-on or OAuth providers to an existing account if the provider returns a verified email.
|
||||||
|
|
||||||
```ts
|
|
||||||
const auth = new BetterAuth({
|
|
||||||
account: {
|
|
||||||
accountLinking: {
|
|
||||||
enabled: false,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also specify a list of trusted providers. If a user signs in using a trusted provider, the account is linked, even if the email verification status is not provided.
|
You can also specify a list of trusted providers. If a user signs in using a trusted provider, the account is linked, even if the email verification status is not provided.
|
||||||
|
|
||||||
If account linking is disabled, accounts cannot be linked, regardless of the provider or email verification.
|
If account linking is disabled, accounts cannot be linked, regardless of the provider or email verification.
|
||||||
|
|
||||||
```ts
|
```ts title="auth.ts"
|
||||||
const auth = new BetterAuth({
|
const auth = new BetterAuth({
|
||||||
account: {
|
account: {
|
||||||
accountLinking: {
|
accountLinking: {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export interface GoogleProfile {
|
|||||||
* Western languages.
|
* Western languages.
|
||||||
*/
|
*/
|
||||||
family_name: string;
|
family_name: string;
|
||||||
/*s*
|
/**
|
||||||
* The given name of the user, or first name in most
|
* The given name of the user, or first name in most
|
||||||
* Western languages.
|
* Western languages.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user