BA
Better Auth•2mo ago
Jan

Custom fields with Magic Links/Social Sign Up

I have a custom field referredBy with my user, which stores the referral code they used to sign up. With email/password signup, I use it as follows:
authClient.signUp.email(
{
email: data.username,
password: data.password,
referredBy: "my-referral-code"
}
)
authClient.signUp.email(
{
email: data.username,
password: data.password,
referredBy: "my-referral-code"
}
)
I'm unsure on how to populate that field on sign up, when signin up using either magic links or social sign-ups. Does someone have any ideas? Thanks!
7 Replies
Jan
JanOP•2mo ago
Bump 😦
iatomic.btc
iatomic.btc•2mo ago
inviteCode: {
type: "string",
required: false,
input: true,
unique: true,
defaultValue: null,
},
inviteCode: {
type: "string",
required: false,
input: true,
unique: true,
defaultValue: null,
},
set input to true
Jan
JanOP•2mo ago
I'm sorry, but I'm not sure if you read my question correctly. I'm not stating that setting the field is not working. It is working with email/password signup. I want to get it to work with magic links, but there is not API documentation on how to do that. Here is my field config:
{
referredBy: {
type: 'string',
defaultValue: null,
required: false,
input: true
}
}
{
referredBy: {
type: 'string',
defaultValue: null,
required: false,
input: true
}
}
Petr Bela
Petr Bela•2mo ago
Maybe add the ?referredBy= to newUserCallbackURL?
Budi
Budi•4w ago
Were you able to get this to work @Jan? I too want to pass a custom value along with a socialSignIn API call. I couldn't get body property nor query param to work. Going to try setting a cookie now and intercepting in the database after hook. I solved this by using cookies. When calling API from the server make sure to pass headers along.
Jan
JanOP•4w ago
I didn‘t, but I will try implementing it using cookies. It would be better, if a native solution would support this though
Takeno
Takeno•4w ago
+1 for this question. I have some important data that must be stored together with the account, but using social authentication there is no way to store them at user creation

Did you find this page helpful?