amazon-cognitoamazon-cognito-facebookamazon-cognito-triggers

How to disable AWS Cognito User Pool account created via Identity Provider?


Any Cognito User Pool gurus out there? I've been using Cognito for a while now but this one has me a bit stumped.

So as I see it I have two options:

Am I missing something obvious?

Thanks in advance!


Solution

  • The simplest solution in the end for us was a Pre Token Generation Trigger in Cognito like this:

    exports.handler = async (event) => {
    
      if(event.triggerSource==="TokenGeneration_HostedAuth") {
    
         //check db/api etc to see if we have a valid registration stored for user
         if(!hasCompletedRegistration) {
    
           //throw auth exception which we can catch on the frontend to inform user
           throw new Error("REGISTRATION_NOT_COMPLETE")
         }
      }
    
      return event
    
    };
    

    For username/password sign ins the TriggerSource will be TokenGeneration_Authentication

    For federated/social sign ins the TriggerSource will be TokenGeneration_HostedAuth