All files / auth pre-signup.js

0% Statements 0/9
0% Branches 0/4
0% Functions 0/1
0% Lines 0/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                                                   
/**
 * Pre-Signup Lambda Trigger
 *
 * Auto-confirms E2E test accounts (e2e-test-*@browsway.com) to enable automated testing.
 * All other users, including internal @browsway.com users, require standard email confirmation.
 */
 
exports.handler = async (event) => {
  console.log('Pre-Signup event:', JSON.stringify(event, null, 2))
 
  // Extract email from user attributes
  const email = event.request.userAttributes.email
 
  // Auto-confirm E2E test accounts only
  if (email && /^e2e-test-.+@browsway\.com$/.test(email)) {
    console.log(`E2E test email detected: ${email} - auto-confirming user`)
    event.response.autoConfirmUser = true
    event.response.autoVerifyEmail = true
  } else {
    console.log(`Regular email: ${email} - requiring email confirmation`)
    // Default behavior: user must confirm via email
  }
 
  return event
}