How can I save additional user information like role "vendor" or "customer" in user table when using
How can I save additional user information like role "vendor" or "customer" in user table when using convex google Auth
Google({
profile(res, tokens) {
console.info({ res, tokens });
return {
id: res.sub,
balance: '0',
fullname: res.name,
email: res.email,
type: res.customer,
};
},
}),
onClick={() =>
signIn('google',
{customer: 'vender'}
})
}
As you can see, customer is not default property of google profile....
I tried like this but can received addtional info
please provide me with guidance?
5 Replies
Customizing Schema - Convex Auth
Authentication library for your Convex backend
You may need to combine with this to fetch and populate: https://labs.convex.dev/auth/api_reference/server#callbacksafterusercreatedorupdated
server - Convex Auth
Authentication library for your Convex backend
Thanks for your reply.
Can I use createOrUpdateUser function to save additional user info not from google profile?
signIn('google', {
createOrUpdateUser: ,
})
if then please provide me with example
Can I use createOrUpdateUser function to save additional user info not from google profile?I believe it can only access information in the profile of whatever OAuth provider you're using (or data already stored in the DB, like a pre-existing account for the same user). https://next-auth.js.org/providers/google is a good starting point for what fields you do have available You can store other information in a separate mutation after authenticating (https://labs.convex.dev/auth/authz#get-currently-signed-in-user-id)
Google | NextAuth.js
Documentation
Authorization - Convex Auth
Authentication library for your Convex backend
This is how I do it! If user already exist, just update his login time, or new users, assign accessLevel 0.
Its done in the backend not frontend.