#1 2019-03-11 20:07:54

Mane
Member
Registered: 2017-02-20
Posts: 15

Custom message on invalid authentication

Hello Everybody,

I've implemented a custom authentication procedure through TSQLRestServer.OnAuthenticationUserRetrieve, and it is working fine.

The thing is that I would like to have some control on the message that gets sent to the users when the authentication fails for any reason. When the authentication fails the sever returns a StatusCode 403 and content with the message "Forbidden".

I would like to be able to change the message to "Invalid Username", "Wrong Password", "Account inactive", etc. I've looked at TSQLRestServer.OnAuthenticationFailed but it doesn't allow for changing the returned message.

It is necessary to subclass TSQLRestServer to change this behaviour or I'm missing something?

Regards,
Mane

Offline

#2 2019-03-11 21:07:47

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Custom message on invalid authentication

You can customize the returned content in the 4th parameter, named Ctxt: TSQLRestServerURIContext.

Try to set your custom message in Ctxt.OutBody.

Offline

#3 2019-03-11 22:11:20

Mane
Member
Registered: 2017-02-20
Posts: 15

Re: Custom message on invalid authentication

Thank you Ab!

Regards,
Mane

Offline

Board footer

Powered by FluxBB