Limit sign in and social sign in to specific domains

Hi @david33,

You can use the Post Login trigger to test for the connection and the email. Since they only work for database connections, the Pre and Post User Registration triggers won’t be fired.

This is how the action should look (modify it for your specific use case):

exports.onExecutePostLogin = async (event, api) => {
 if (event.connection.id === "{google connection id}") {
   let split = event.user.email?.split('@');
   if (!split) { // check if the split was done successfully
     return;
   }

   let domain = split[1];
   if (domain === "{domain you need to check against}") {
     api.access.deny("Access denied");
   }
 }
};

After creating the action, add it to the flow and save it.

If you have any other questions, feel free to reach out.

Have a good one,
Vlad