How to handle errors on Custom Function Authentication?

There is a way to handle errors on Custom Function Authentication?
no matter what i return, always i got this

{ message: ‘auth function result must include id field’,
code: 47 }

Hi @Royal_Advice,

A custom function auth requires the function to return either a string of a unique id for authenticated user (so realm could map it to its internal user) or and object with “id” field and the unique value.

return "5f650356a8631da45dd4784c"
return { "id": "5f650356a8631da45dd4784c" }
return { "id": "5f650356a8631da45dd4784c", "name": "James Bond" }

The above are valid outputs, any other type will result with the received error.

Best
Pavel

Ok, when all requisites match i return the id, its ok
but if i need to handle errors? user exist, password dont match?

@Royal_Advice just throw an error.

1 Like

@Royal_Advice It sounds like you want to have a meaningful response when authentication fails based on different problems. Unfortunately, Custom Function Authentication offers no way to do this. However, if you look at the last solution in my advice thread, you can set up an Incoming Webhook to call your authentication function directly first to find any potential problems. If you find no problems, you then call login() as usual.

Unfortunately, it took many such hacks to get Custom Function Authentication working as desired.

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