From what I can tell, $user->isLoggedIn() tells whether a user object is an anonymous one or one with an id in the user table. Is there a function that actually can tell if a user is logged in? I'm not trying to display this in the wiki, I'm trying to integrate logging into the wiki into the login system of a blogging package I have. I realize that most authentication packages do it the other way, but I'd like to try making the blog treat users as logged in if they are logged into the wiki.
I'm guessing that there must be session info that I can use somewhere. My thought is to have the blog send a query on a private port or via the shell to something that responds if the username matches someone who is logged in. My first attempt:
<?php require_once("./includes/WebStart.php" ); require_once("./includes/Wiki.php" ); $mediaWiki = new MediaWiki(); $wikiUser = User::newFromName($_REQUEST['user']); if($wikiUser->isLoggedIn()){ echo "y"; } else{ echo "n"; } ?>
returns Y whether the user is logged in or not, for the reason described above.
Jim
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
On 8/31/07, Jim Hu jimhu@tamu.edu wrote:
From what I can tell, $user->isLoggedIn() tells whether a user object is an anonymous one or one with an id in the user table. Is there a function that actually can tell if a user is logged in? I'm not trying to display this in the wiki, I'm trying to integrate logging into the wiki into the login system of a blogging package I have. I realize that most authentication packages do it the other way, but I'd like to try making the blog treat users as logged in if they are logged into the wiki.
I'm guessing that there must be session info that I can use somewhere. My thought is to have the blog send a query on a private port or via the shell to something that responds if the username matches someone who is logged in. My first attempt:
<?php require_once("./includes/WebStart.php" ); require_once("./includes/Wiki.php" ); $mediaWiki = new MediaWiki(); $wikiUser = User::newFromName($_REQUEST['user']); if($wikiUser->isLoggedIn()){ echo "y"; } else{ echo "n"; } ?>
returns Y whether the user is logged in or not, for the reason described above.
Jim
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
All users regardless of whether they are logged in or not have a user ID (anonymous == user id 0) so the only check that needs to be made is whether the user id is a positive integer.
On Aug 31, 2007, at 2:09 PM, Minute Electron wrote:
On 8/31/07, Jim Hu jimhu@tamu.edu wrote:
From what I can tell, $user->isLoggedIn() tells whether a user
<snip>
All users regardless of whether they are logged in or not have a user ID (anonymous == user id 0) so the only check that needs to be made is whether the user id is a positive integer.
From what I can tell, $user->isLoggedIn returns the userid in the database, but $_SESSION['wsUserID'] behaves as you describe, changing from 0 to 1 and back when I log in or out. Interestingly, it seems to not care if I'm viewing the wiki from different browsers, while MW itself recognizes them as different sessions. I think I can live with that.
Now I just have to get the blog to be able to send a logout to both itself and the wiki, which I'm guessing I can do by overwriting $_SESSION['wsUserID'].
Thanks!
JH
-- MinuteElectron. http://my.brlcad.org/~MinuteElectron/
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
It looks like detecting login may be even easier. I'm seeing stuff in $_REQUEST that may work without even adding scripts to the wiki.
JH
On Aug 31, 2007, at 2:20 PM, Jim Hu wrote:
On Aug 31, 2007, at 2:09 PM, Minute Electron wrote:
On 8/31/07, Jim Hu jimhu@tamu.edu wrote:
From what I can tell, $user->isLoggedIn() tells whether a user
<snip> > All users regardless of whether they are logged in or not have a user > ID (anonymous == user id 0) so the only check that needs to be > made is > whether the user id is a positive integer.
From what I can tell, $user->isLoggedIn returns the userid in the database, but $_SESSION['wsUserID'] behaves as you describe, changing from 0 to 1 and back when I log in or out. Interestingly, it seems to not care if I'm viewing the wiki from different browsers, while MW itself recognizes them as different sessions. I think I can live with that.
Now I just have to get the blog to be able to send a logout to both itself and the wiki, which I'm guessing I can do by overwriting $_SESSION['wsUserID'].
Thanks!
JH
-- MinuteElectron. http://my.brlcad.org/~MinuteElectron/
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
Spoke too soon. The test script responds to being logged in or logged out, but calling it from a different script using file_get_contents isn't working.
On Aug 31, 2007, at 2:28 PM, Jim Hu wrote:
It looks like detecting login may be even easier. I'm seeing stuff in $_REQUEST that may work without even adding scripts to the wiki.
JH
On Aug 31, 2007, at 2:20 PM, Jim Hu wrote:
On Aug 31, 2007, at 2:09 PM, Minute Electron wrote:
On 8/31/07, Jim Hu jimhu@tamu.edu wrote:
From what I can tell, $user->isLoggedIn() tells whether a user
<snip> > All users regardless of whether they are logged in or not have a > user > ID (anonymous == user id 0) so the only check that needs to be > made is > whether the user id is a positive integer.
From what I can tell, $user->isLoggedIn returns the userid in the database, but $_SESSION['wsUserID'] behaves as you describe, changing from 0 to 1 and back when I log in or out. Interestingly, it seems to not care if I'm viewing the wiki from different browsers, while MW itself recognizes them as different sessions. I think I can live with that.
Now I just have to get the blog to be able to send a logout to both itself and the wiki, which I'm guessing I can do by overwriting $_SESSION['wsUserID'].
Thanks!
JH
-- MinuteElectron. http://my.brlcad.org/~MinuteElectron/
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
file_get_contents won't ever work with sessions because it's the server getting contents, not the client's computer. So the session would be a single server session. User::isLoggedIn() was meant to be used with $wgUser, as in. You're logged in if "$wgUser->isLoggedIn();" returns true. It's not meant to detect if an other user is logged in, because that's a technical impossibility. Since you're including the WebStart, perhaps you should try using $wgUser.
~Daniel Friesen(Dantman) of The Gaiapedia, Wikia Graphical Entertainment Project, and Wiki-Tools.com
Jim Hu wrote:
Spoke too soon. The test script responds to being logged in or logged out, but calling it from a different script using file_get_contents isn't working.
On Aug 31, 2007, at 2:28 PM, Jim Hu wrote:
It looks like detecting login may be even easier. I'm seeing stuff in $_REQUEST that may work without even adding scripts to the wiki.
JH
On Aug 31, 2007, at 2:20 PM, Jim Hu wrote:
On Aug 31, 2007, at 2:09 PM, Minute Electron wrote:
On 8/31/07, Jim Hu jimhu@tamu.edu wrote:
From what I can tell, $user->isLoggedIn() tells whether a user
<snip>
All users regardless of whether they are logged in or not have a user ID (anonymous == user id 0) so the only check that needs to be made is whether the user id is a positive integer.
From what I can tell, $user->isLoggedIn returns the userid in the database, but $_SESSION['wsUserID'] behaves as you describe, changing from 0 to 1 and back when I log in or out. Interestingly, it seems to not care if I'm viewing the wiki from different browsers, while MW itself recognizes them as different sessions. I think I can live with that.
Now I just have to get the blog to be able to send a logout to both itself and the wiki, which I'm guessing I can do by overwriting $_SESSION['wsUserID'].
Thanks!
JH
-- MinuteElectron. http://my.brlcad.org/~MinuteElectron/
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Thanks. I was coming to that conclusion myself, so I decided to use the UserLoginComplete and UserLogout hooks to record login/logout activity in a tmp directory that is accessible to the blog. Advice on the security issues created by this approach is welcome!!
Jim
On Aug 31, 2007, at 4:47 PM, DanTMan wrote:
file_get_contents won't ever work with sessions because it's the server getting contents, not the client's computer. So the session would be a single server session. User::isLoggedIn() was meant to be used with $wgUser, as in. You're logged in if "$wgUser->isLoggedIn();" returns true. It's not meant to detect if an other user is logged in, because that's a technical impossibility. Since you're including the WebStart, perhaps you should try using $wgUser.
~Daniel Friesen(Dantman) of The Gaiapedia, Wikia Graphical Entertainment Project, and Wiki-Tools.com
Jim Hu wrote:
Spoke too soon. The test script responds to being logged in or logged out, but calling it from a different script using file_get_contents isn't working.
On Aug 31, 2007, at 2:28 PM, Jim Hu wrote:
It looks like detecting login may be even easier. I'm seeing stuff in $_REQUEST that may work without even adding scripts to the wiki.
JH
On Aug 31, 2007, at 2:20 PM, Jim Hu wrote:
On Aug 31, 2007, at 2:09 PM, Minute Electron wrote:
On 8/31/07, Jim Hu jimhu@tamu.edu wrote:
From what I can tell, $user->isLoggedIn() tells whether a user
<snip>
All users regardless of whether they are logged in or not have a user ID (anonymous == user id 0) so the only check that needs to be made is whether the user id is a positive integer.
From what I can tell, $user->isLoggedIn returns the userid in the database, but $_SESSION['wsUserID'] behaves as you describe, changing from 0 to 1 and back when I log in or out. Interestingly, it seems to not care if I'm viewing the wiki from different browsers, while MW itself recognizes them as different sessions. I think I can live with that.
Now I just have to get the blog to be able to send a logout to both itself and the wiki, which I'm guessing I can do by overwriting $_SESSION['wsUserID'].
Thanks!
JH
-- MinuteElectron. http://my.brlcad.org/~MinuteElectron/
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
User::isLoggedIn() was meant to be used with $wgUser, as in. You're logged in if "$wgUser->isLoggedIn();" returns true. It's not meant to detect if an other user is logged in, because that's a technical impossibility.
It's a bad name, really. It should be something is isNotAnon(), since that's what it actually does.
mediawiki-l@lists.wikimedia.org