SphinxLogin not redirecting without refresh


i want to check the Authentification Status of a user, accessing my Homepage/Application with Sphinx.
So i made a function on the start of the Application which checks the sphinxweblogin.isloggedin value.

procedure StartApplication;
  if (not dmAuth.SphinxWebLogin.IsLoggedIn) then

If the user is already authenticated, he directly gets redirected.(ex. www.myhompage/xdata/UserPortal)
When he is not, he has to login first via SphinxWeblogin.Login.

After he has successfully Logged in i want him also to be redirected to the application.(www.myhompage/xdata/UserPortal) but that's not working correctly.
I always have to refresh/restart the Page, so that the initial Authentification Check is made and only then the user gets to the UserPortal.
Is there something i'm missing out?
Do i have to call the redirectURL, configured in the SphinxWebLogin, again on the " OnUserLoggedIn" function?

I hope you understand my problem.

Thanks and kind regards,

What is the URL of your web application?
What did you set as the redirect URL of the authorization flow?
When is StartApplication called?
What HTTP requests are performed after the user successfully logs in (you can see it in the network tab of your browser's developer tool).

Usually not. Sphinx will automatically call the redirect URI you setup after the user is logged in. When calling that URL, if your code executes StartApplication, it should work.

But yes, you can also use OnUserLoggedIn event, that's what it is for, it's executed when the user is logged in, regardless if because it entered the user name and password, or simply because it was already logged in when the application is started (more specifically, when the TSphinxWebLogin component is instantiated and loaded from the data module.

Thanks for the fast reply.
Q1 and Q2:
The URL of my web application and the Redirect-URL are the same: www.myhompage/xdata/UserPortal.
On Progamm Startup. Actually in the same position as you have it in your Xdata Music Demo.
I checked in the developer Tools what happens after Login and i get the error
fMessage:"Missing required parameter: Issuer".

Thinking about it, the position of the StartApplication might be the problem, because it's not recalled after the Login process, right?
The recursive way, used in the Xdata Demo wont work with Sphinx, right?

Kind regards,

Maybe, I can't tell.
Maybe it's easier if you reduce your test projects to a minimum and send client/server to us here, and provide steps to reproduce? So we can objectively see what's going on and provide a fix.

So i changed the Demo at the important points.

So when u call


the first time, u will be redirected to the Login Page.
After the Login i would like the user to get redirected to the Portal.
But this form is only shown, when u hit F5 or recall the URL.

Simple.zip (1.8 MB)

It has to do with the asynchronous nature of web applications. The data module is loaded asynchronously, thus your StartApplication might be executed before the data module and sphinx login is executed.

It's safer to just use OnUserLoggedIn. I have attached the updated WebClient project which works the way you want.

WebClient.zip (8.2 KB)

Thank you very much!

1 Like

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