I am working on a food delivery webapp. So there will be two types of users, 1. customer. 2. vendor. I can set custom permission on tables for two users in hasura console. Now how to implement the authentication setup where user can signup/login two the website with this two different roles. In auth0 or firebase we can't have that feature. So custom auth server is the only option. So my question here is - how to run the jwt script that we run in auth0 to pass those season variables.?
function (user, context, callback) {
const namespace = "https://hasura.io/jwt/claims";
context.idToken[namespace] =
{
'x-hasura-default-role': 'user',
// do some custom logic to decide allowed roles
'x-hasura-allowed-roles': ['user'],
'x-hasura-user-id': user.user_id
};
callback(null, user, context);
}
And do I need to write this auth service as custom resolver and add it as remote schema? How do I run the database operation in the resolver?