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

[Docs]: clarify getUserAttributes() should mention how it handles the user id column #1648

Open
PeytonHanel opened this issue Jul 26, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@PeytonHanel
Copy link

Description

Requesting a simple clarification here: https://lucia-auth.com/basics/configuration#getuserattributes

When using getUserAttributes(), it's expected that any attribute specified there will show up. The docs do not mention how it handles the user id differently from the rest of the attributes. So if a developer is doing something like what I did:

getUserAttributes: (attributes) => {
        return {
            // each attribute has the type defined in DatabaseUserAttributes
            /** Only available on the server */
            server: {
                phone: attributes.phone,
                addressId: attributes.address_id,
            },
            /** Available client-side and server-side */
            client: {
                id: attributes.id,
                phoneVerifiedOn: attributes.phone_verified_on,
                hasAddress: attributes.address_id !== null,
            },
        };
    }
export async function load({ locals }) {
  return {
    // prevents server-side user data from going to the client
    user: locals.user?.client || null,
  }
}

...id is left undefined and confusion ensues.
A developer could figure this out by looking at the interface here but it wasn't immediately obvious to me.
Thank you

@PeytonHanel PeytonHanel added the documentation Improvements or additions to documentation label Jul 26, 2024
@pilcrowonpaper
Copy link
Member

The docs mentions that it's typed as Register.DatabaseUserAttributes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants