Tom S. Posted October 12, 2017 Posted October 12, 2017 From a remote server I wish to see if a user is logged in to the application. I have set up the REST API but I don't know what method to call to simply check if a user is logged in or not.
Tom S. Posted October 13, 2017 Author Posted October 13, 2017 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
Aiwa Posted October 13, 2017 Posted October 13, 2017 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.
Tom S. Posted October 13, 2017 Author Posted October 13, 2017 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.
bfarber Posted October 13, 2017 Posted October 13, 2017 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.