lucia-auth/lucia

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

PeytonHanel opened this issue · 1 comments

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

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