fedeya / next-auth-sanity

NextAuth Adapter and Provider for Sanity
https://sanity.io/plugins/next-auth-sanity
MIT License
78 stars 20 forks source link

Sign-up - option to pass in additional user values #10

Closed Adstokoe19 closed 1 year ago

Adstokoe19 commented 1 year ago

Currently if you are creating a new user, the following fields are mapped across: 'email, name, image and password'. It would be nice if you could pass in additional values for custom schema used instead of the default user schema.

fedeya commented 1 year ago

Hi @Adstokoe19! are you talking about the signUp function or the sign in with a provider like a github?

Adstokoe19 commented 1 year ago

Hi @Fedeya both if possible. I have a custom login page where the user can sign in with their credentials or Facebook (as a provider) and a sign up form. When the user is created in Sanity, I would like to assign them a group and role. One way to do this would be using query parameters e.g. /login?group=value&role=value /sign-up?group=value&role=value

These additional values would need to be added to the newUser request?

fedeya commented 1 year ago

@Adstokoe19 next auth have a way for set custom profile data, using the profile callback in the provider

here you can see some examples

but this lib i think is not working with that profile callback, probably I need to do a fix

and with the sign up with credentials I think is better approach get that data in the sign up function and in the body of the api route

let me know what you think 😀

Adstokoe19 commented 1 year ago

@Fedeya if you could implement the profile callback into you lib that would be great! Re sign up with credentials, your suggestion sounds good. Both options will require updates to your lib?

Adstokoe19 commented 1 year ago

@Fedeya any further thoughts on this? Cheers.

fedeya commented 1 year ago

Hi @Adstokoe19, i created this pr #11 this should be fix the problems sending more data in the provider using the profile callback, and in the signUp function