Skip to content

Option to deconstruct session to select which id to use for externalId (better-auth) #196

@MatthewDavidTravers

Description

@MatthewDavidTravers

Currently all interactions when using the better-auth plugin are done via the user.id which references the customer.externalId in Polar. Better-auth allows the concept of organisations through the organisation plugin. It would be good to allow the polar plugin to decide what will be used as the referencing id.

A possible solution could be to give a callback function in the configuration of the plugin that allows the user to decide how we deconstruct the session to get the ID.

something like:

export const auth = betterAuth({
  plugins: [
    polar({
      getExternalId(session) {
        return session.session.activeOrganizationId;
      }
    })
  ]
});

if this is not possible are there other ways this could be achieved currently?

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions