Auth0 Home Blog Docs

Execute javascript in Lock after custom validation error

lock
custom-database
universal-login
#1

I’m trying to control the behaviour of Universal Login page in the reaction to errors encounter during the user migration.

In the database script, I send a validation error when I cannot migrate the user.

function login(email, password, callback) {
    // [...]
   return callback(new ValidationError('custom_validation_error_code', 'message'));
}

I would like to inform the user about the specific issue with this migration of this account when login and password are valid.
I can do that by showing the right message but I would like also to do a few additional operations in JS.

var lock = new Auth0Lock([...]);

lock.on("authorization_error", function(error) {
  /// [...] code to control behaviour of the page
});

// below code will not work beacuse it doesn't recognise `custom_validation_error_code` as an event.
lock.on("custom_validation_error_code", function(error){
  /// [...] code to control behaviour of the page
});

Unfortunately, Lock doesn’t provide the possibility to react to such a event. Is there any possibility react in javascript on a custom validation error?

#3

Hey there @robert.firek, when it comes to Lock we do have the ability to customize Lock error messages as described in the below doc. However I could be totally missing the base here and you have a different question all together. Please let me know if this helps you in your quest at all. Thanks!

#4

I can customise messages but I don’t have the ability to execute javascript in the reaction to this event:

// below code will not work because it doesn't recognise `custom_validation_error_code` as an event.
lock.on("custom_validation_error_code", function(error){
    /// [...] code to control behaviour of the page
});

Is it possible to implement the above behaviour?

#5

I checked with one of our senior support engineers and I was able to confirm that it’s not possible with Lock. However this should be possible when working with the hosted login page with Auth0.js a full custom implementation. Sadly we don’t have any examples of this implementation use case. I hope this helps provide some insight @robert.firek, thanks!

1 Like
closed #6

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