Jump to content

How to check if user is logged in using REST API


Tom S.

Recommended Posts

I should clarify,

I want to check if a user is logged in using the same web browser. So lets say the master application is located:

app.mysite.com

and the slave application is

mysite.com.

I want to be able to check from mysite.com if a user is signed into app.mysite.com

Link to comment
Share on other sites

About the only reliable option there would be to check the sessions table for that member ID, but it's not exposed via the REST API. 

The REST API isn't designed, or intended, to authenticate or check for authentication. That's what IPS Connect or SSO's are for. 

Link to comment
Share on other sites

30 minutes ago, Aiwa said:

About the only reliable option there would be to check the sessions table for that member ID, but it's not exposed via the REST API. 

The REST API isn't designed, or intended, to authenticate or check for authentication. That's what IPS Connect or SSO's are for. 

I've tried using:

/* Require the init.php file from the Community Suite root directory */
require '/path/to/suite/init.php';

/* Initiate the session to verify who this user is */
\IPS\Session\Front::i();

/* Print the user's name */
print \IPS\Member::loggedIn()->name;

However, it doesn't work across subdomains.

Link to comment
Share on other sites

You can't do this via the REST API at this time. The REST API is a server-to-server API and has no knowledge of the user that may trigger it to run.

Your sample code would work, however you would first need to adjust your Suite installation to set cookies across the parent domain if it's on a separate subdomain.

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...