beforeLogin Server Code

Hi,

I understand that the business logic has event handlers for user login. Can we disallow the login in beforeLogin handler after checking certain parameters?

Yes, you should be able to stop the execution of the default login logic by throwing an exception out of the beforeLogin event handler.

Regards,
Mark

Oh, I was hoping for a more elegant solution. I was thinking more along the line of returning true/false to halt the execution rather than an exception. Nonetheless, this would do as well.

Thanks a lot!

Make sure the handler is not marked as “Async”. Responses/exceptions from the asynchronous handlers are ignored.

If you’d like to get somewhat elegant errors write your own cloud function.

Its possible throw a BackendlessException with message and code like this:

throw new BackendlessServerException(new BackendlessExceptionMessage(1234, "My error message"));

Just handle the code on your client.