Apple provider sets users name as their email #2640

Closed
opened 2026-03-13 10:10:10 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @darrencarlin on GitHub (Jan 2, 2026).

Originally assigned to: @bytaesu on GitHub.

Is this suited for github?

  • Yes, this is suited for github

I am using the Apple provider for my app and I've noticed in my database that some people who sign up with this end up having their name set as their email.

My app is a public facing review website and react native app so having their emails shown publicly is not ideal.

I've added a database hook to fix this for now generating a random name.

I believe this code is the culprit:

const name = token.user
	? `${token.user.name?.firstName} ${token.user.name?.lastName}`
	: profile.name || profile.email;

a420081245/packages/core/src/social-providers/apple.ts (L164)

I did search through the issues and didn't find anything similar so figured I would report this issue. Happy to make a PR if we think this is worth changing.

Current vs. Expected behavior

Current:

When a user signs up, their name is set as their email.

Expected

When a user signs up, their name should not be their email.

What version of Better Auth are you using?

1.3.31

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000",
    "release": "25.1.0",
    "cpuCount": 10,
    "cpuModel": "Apple M1 Max",
    "totalMemory": "32.00 GB",
    "freeMemory": "0.19 GB"
  },
  "node": {
    "version": "v22.20.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.6.4"
  },
  "frameworks": [
    {
      "name": "react",
      "version": "19.2.0"
    },
    {
      "name": "hono",
      "version": "^4.9.9"
    }
  ],
  "databases": [
    {
      "name": "pg",
      "version": "^8.16.3"
    },
    {
      "name": "drizzle",
      "version": "^0.44.6"
    },
    {
      "name": "@neondatabase/serverless",
      "version": "^1.0.2"
    }
  ],
  "betterAuth": {
    "version": "^1.3.31",
    "config": {
      "appName": "The Guinness Map",
      "baseURL": "http://localhost:8000/api/auth",
      "databaseHooks": {
        "user": {
          "create": {}
        }
      },
      "trustedOrigins": [
      ],
      "advanced": {
        "disableOriginCheck": true,
        "defaultCookieAttributes": {
          "sameSite": "lax",
          "secure": false
        },
        "database": {}
      },
      "emailAndPassword": {
        "enabled": true,
        "requireEmailVerification": true,
        "password": {}
      },
      "emailVerification": {
        "sendOnSignUp": true,
        "autoSignInAfterVerification": true
      },
      "socialProviders": {
        "google": {
          "prompt": "select_account",
          "clientId": "[REDACTED]",
          "clientSecret": "[REDACTED]",
          "accessType": "offline"
        },
        "apple": {
          "clientId": "[REDACTED]",
          "clientSecret": "[REDACTED]",
          "appBundleIdentifier": "com.darrencarlin.theguinnessmap"
        }
      },
      "account": {
        "accountLinking": {
          "enabled": true,
          "trustedProviders": [
            "google",
            "twitter",
            "apple"
          ],
          "allowDifferentEmails": false
        }
      },
      "user": {
        "additionalFields": {
          "username": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "bio": {
            "type": "string"
          },
          "badges": {
            "type": "string[]"
          },
          "publicProfile": {
            "type": "boolean"
          },
          "reviewCount": {
            "type": "number"
          },
          "checkInCount": {
            "type": "number"
          },
          "platform": {
            "type": "string"
          }
        }
      },
      "plugins": [
        {
          "name": "expo",
          "config": {
            "id": "expo",
            "hooks": {
              "after": [
                {}
              ]
            },
            "endpoints": {}
          }
        },
        {
          "name": "open-api",
          "config": {
            "id": "open-api",
            "endpoints": {}
          }
        }
      ]
    }
  }
}

Which area(s) are affected? (Select all that apply)

Backend, Client

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @darrencarlin on GitHub (Jan 2, 2026). Originally assigned to: @bytaesu on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github I am using the Apple provider for my app and I've noticed in my database that some people who sign up with this end up having their name set as their email. My app is a public facing review website and react native app so having their emails shown publicly is not ideal. I've added a database hook to fix this for now generating a random name. I believe this code is the culprit: ```ts const name = token.user ? `${token.user.name?.firstName} ${token.user.name?.lastName}` : profile.name || profile.email; ``` https://github.com/better-auth/better-auth/blob/a420081245802cb77392c24f6c495076d27593b4/packages/core/src/social-providers/apple.ts#L164 I did search through the issues and didn't find anything similar so figured I would report this issue. Happy to make a PR if we think this is worth changing. ### Current vs. Expected behavior Current: When a user signs up, their name is set as their email. Expected When a user signs up, their name should not be their email. ### What version of Better Auth are you using? 1.3.31 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000", "release": "25.1.0", "cpuCount": 10, "cpuModel": "Apple M1 Max", "totalMemory": "32.00 GB", "freeMemory": "0.19 GB" }, "node": { "version": "v22.20.0", "env": "development" }, "packageManager": { "name": "npm", "version": "11.6.4" }, "frameworks": [ { "name": "react", "version": "19.2.0" }, { "name": "hono", "version": "^4.9.9" } ], "databases": [ { "name": "pg", "version": "^8.16.3" }, { "name": "drizzle", "version": "^0.44.6" }, { "name": "@neondatabase/serverless", "version": "^1.0.2" } ], "betterAuth": { "version": "^1.3.31", "config": { "appName": "The Guinness Map", "baseURL": "http://localhost:8000/api/auth", "databaseHooks": { "user": { "create": {} } }, "trustedOrigins": [ ], "advanced": { "disableOriginCheck": true, "defaultCookieAttributes": { "sameSite": "lax", "secure": false }, "database": {} }, "emailAndPassword": { "enabled": true, "requireEmailVerification": true, "password": {} }, "emailVerification": { "sendOnSignUp": true, "autoSignInAfterVerification": true }, "socialProviders": { "google": { "prompt": "select_account", "clientId": "[REDACTED]", "clientSecret": "[REDACTED]", "accessType": "offline" }, "apple": { "clientId": "[REDACTED]", "clientSecret": "[REDACTED]", "appBundleIdentifier": "com.darrencarlin.theguinnessmap" } }, "account": { "accountLinking": { "enabled": true, "trustedProviders": [ "google", "twitter", "apple" ], "allowDifferentEmails": false } }, "user": { "additionalFields": { "username": { "type": "string" }, "country": { "type": "string" }, "url": { "type": "string" }, "bio": { "type": "string" }, "badges": { "type": "string[]" }, "publicProfile": { "type": "boolean" }, "reviewCount": { "type": "number" }, "checkInCount": { "type": "number" }, "platform": { "type": "string" } } }, "plugins": [ { "name": "expo", "config": { "id": "expo", "hooks": { "after": [ {} ] }, "endpoints": {} } }, { "name": "open-api", "config": { "id": "open-api", "endpoints": {} } } ] } } } ``` ### Which area(s) are affected? (Select all that apply) Backend, Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the social-provider label 2026-03-13 10:10:10 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Jan 2, 2026):

It seems you've encountered a situation where user names are being set to their email addresses when signing up through the Apple provider in your application. You've pinpointed the code responsible for this behavior, which defaults to using the email when the user's name isn't fully parsed.

This behavior appears to be a known issue. As you mentioned, many developers have found this to be problematic, especially in public-facing applications where email addresses shouldn't be displayed as names.

To address this issue, you could propose a change in the code you referenced, or alternatively, consider implementing a fix on your end as you've done by generating a random name for users who sign up via Apple.

If you're interested in pursuing a change to the Better Auth library itself, feel free to draft a Pull Request (PR). The community can benefit greatly from improvements like these! Additionally, if you'd like more insight or suggestions, consider tagging Beka and Max (@bekacru, @ping__) to get their input on this matter.

What do you think your next steps will be? Would you attempt to draft a PR for this behavior?

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Jan 2, 2026): It seems you've encountered a situation where user names are being set to their email addresses when signing up through the Apple provider in your application. You've pinpointed the code responsible for this behavior, which defaults to using the email when the user's name isn't fully parsed. This behavior appears to be a known issue. As you mentioned, many developers have found this to be problematic, especially in public-facing applications where email addresses shouldn't be displayed as names. To address this issue, you could propose a change in the code you referenced, or alternatively, consider implementing a fix on your end as you've done by generating a random name for users who sign up via Apple. If you're interested in pursuing a change to the Better Auth library itself, feel free to draft a Pull Request (PR). The community can benefit greatly from improvements like these! Additionally, if you'd like more insight or suggestions, consider tagging Beka and Max (@bekacru, @ping__) to get their input on this matter. What do you think your next steps will be? Would you attempt to draft a PR for this behavior? _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@DemaPy commented on GitHub (Jan 3, 2026):

@darrencarlin i think this is expected behavior

@DemaPy commented on GitHub (Jan 3, 2026): @darrencarlin i think this is expected behavior
Author
Owner

@nicolascavallin commented on GitHub (Jan 4, 2026):

@DemaPy why expected? I'm facing same issue

@nicolascavallin commented on GitHub (Jan 4, 2026): @DemaPy why expected? I'm facing same issue
Author
Owner

@DemaPy commented on GitHub (Jan 5, 2026):

@nicolascavallin because this is how code behaves in this auth library. They have added check, id name not exist use email.

You have to providd fix by your end. Just che k whether it is apple and email === name, o you can hide name.

@DemaPy commented on GitHub (Jan 5, 2026): @nicolascavallin because this is how code behaves in this auth library. They have added check, id name not exist use email. You have to providd fix by your end. Just che k whether it is apple and email === name, o you can hide name.
Author
Owner

@nicolascavallin commented on GitHub (Jan 5, 2026):

@DemaPy sorry, I misunderstood. Yes, is expected since no name, surname, full-name is provided by Apple, then use the email, but I was testing, and this are my logs:

 LOG  Credential: {"email": "REDACTED", "fullName": {"familyName": "Cavallin", "givenName": "Nicolas", "middleName": null, "namePrefix": null, "nameSuffix": null, "nickname": null}, "hasAuthorizationCode": true, "hasIdentityToken": true, "realUserStatus": 2, "user": "001341.REDACTED.1128"}
 LOG  JWT FULL payload: {"aud": "REDACTED", "auth_time": 1767648198, "c_hash": "REDACTED", "email": "REDACTED", "email_verified": true, "exp": 1767734598, "iat": 1767648198, "iss": "https://appleid.apple.com", "nonce_supported": true, "real_user_status": 2, "sub": "001341.REDACTED.1128"}

My concern was if Apple was providing or not the data, and seems yes, even, with this payload, I get email as name in better-auth.

@nicolascavallin commented on GitHub (Jan 5, 2026): @DemaPy sorry, I misunderstood. Yes, is expected since no name, surname, full-name is provided by Apple, then use the email, but I was testing, and this are my logs: ``` LOG Credential: {"email": "REDACTED", "fullName": {"familyName": "Cavallin", "givenName": "Nicolas", "middleName": null, "namePrefix": null, "nameSuffix": null, "nickname": null}, "hasAuthorizationCode": true, "hasIdentityToken": true, "realUserStatus": 2, "user": "001341.REDACTED.1128"} LOG JWT FULL payload: {"aud": "REDACTED", "auth_time": 1767648198, "c_hash": "REDACTED", "email": "REDACTED", "email_verified": true, "exp": 1767734598, "iat": 1767648198, "iss": "https://appleid.apple.com", "nonce_supported": true, "real_user_status": 2, "sub": "001341.REDACTED.1128"} ``` My concern was if Apple was providing or not the data, and seems yes, even, with this payload, I get email as name in better-auth.
Author
Owner

@bytaesu commented on GitHub (Jan 7, 2026):

Hi, I'm thinking about this!

@bytaesu commented on GitHub (Jan 7, 2026): Hi, I'm thinking about this!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2640