Auth0 Home Blog Docs

Capture event for social button click for lock on hosted universal login page

Hi, due to business requirements I need to display a consent / permission dialog before allowing a user to login on a custom social connection provider. Is there any way to capture the click event so I can display this dialog before proceeding?

Hey @customautosys, are you only trying to trigger an event on a successful login? If so a rule should be able to help you do the trick. I have linked the standard doc below related to rules but If I am mistaken in the desired effect please let me know and I will be happy to help. Have a happy holidays!

No, is it possible to display a dialog box before it goes to the custom social provider’s login page? Before the user even logs in (but immediately after the button is clicked).

You may be able to accomplish that leveraging the Management API and some custom code but there isn’t a default ability to accomplish this. If you could share more details on the use case I would be happy to submit it as a feature request. Thanks!

It’s to display a permissions dialog to the user which is a requirement by my custom social connection provider.

Currently I’m able to hook the event, but is there a way to stop the event progressing to the next page and proceed only if the user clicks OK on a custom popup (currently I’m able to show an alert box, but it’s ugly).

I’m guessing you found the federated login event. As you say, unfortunately, this event was added mainly for analytics data collecting, but does not provide a way to cancel the action.

A few options:

  • Use Auth0.js instead of Lock to build your own login UI, with full customization capabilities. This is unfortunately a rather extreme option, as it requires you to take care of a lot of work currently handled by Lock.
  • Fork the Lock repository and modify it to make the event cancellable. Submit a PR for the team to analyze and hopefully merge it in the codebase.
  • Create a GH issue in the repository and ask the Lock team to support the cancellation of events. There’s no guarantee, though, of when (and if) they would do it.
1 Like

Hi, currently my kludge is to directly query the DOM element, get the React object, hook an onclick to the DOM element that pops up my custom dialog, then if the user agrees it will call the original onclick handler on the React object otherwise it will remain on the current page and revert to the Lock screen. Obviously, this is horribly hacky and undesirable so I hope that somebody can give me some help to do a better implementation.

The “federated login” event cannot work for my purposes as it fires too late.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.