0

In Amazon Cognito, when selecting a user, I can see the auth events below, e.g.

enter image description here

My question is, how may I retrieve these auth events for displaying in the UI?

So far I have been using the Auth library in AWS Amplify to sign in and sign out, as part of an Angular app. I cannot see anything on the Auth class to do this.

1 Answer 1

0

On the client you can use Hub

https://docs.amplify.aws/lib/utilities/hub/q/platform/js#authentication-events

import { Hub, Logger } from 'aws-amplify';

const logger = new Logger('My-Logger');

const listener = (data) => {

    switch (data.payload.event) {

        case 'signIn':
            logger.error('user signed in'); //[ERROR] My-Logger - user signed in
            break;
        case 'signUp':
            logger.error('user signed up');
            break;
        case 'signOut':
            logger.error('user signed out');
            break;
        case 'signIn_failure':
            logger.error('user sign in failed');
            break;
        case 'configured':
            logger.error('the Auth module is configured');

    }
}

Hub.listen('auth', listener);
2
  • Thank you for the answer. I think this will set up a listener for new events, not allow me to retrieve historic events, is that correct? Sep 17, 2020 at 15:12
  • I think you will probably have to reach out to some aws-sdk apis to get this feature going Sep 20, 2020 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.