/** * Auth0 Action: Add User Info to Token * * This action adds user profile information to the access token * so the backend can create/validate users properly. * * Deploy this in Auth0 Dashboard: * 1. Go to Actions → Flows → Login * 2. Click "+" → Build from scratch * 3. Name: "Add User Info to Token" * 4. Copy this code * 5. Click Deploy * 6. Drag into flow between Start and Complete * 7. Click Apply */ exports.onExecutePostLogin = async (event, api) => { const namespace = 'https://vip-coordinator-api'; if (event.authorization) { // Add user profile to access token api.accessToken.setCustomClaim(`${namespace}/email`, event.user.email); api.accessToken.setCustomClaim(`${namespace}/name`, event.user.name); api.accessToken.setCustomClaim(`${namespace}/picture`, event.user.picture); api.accessToken.setCustomClaim(`${namespace}/email_verified`, event.user.email_verified); // Optionally require email verification before allowing access // Uncomment the lines below if you want to enforce email verification /* if (!event.user.email_verified) { api.access.deny('Please verify your email before accessing the application.'); } */ } };