MediaWiki master
|
Object holding data about a session's user. More...
Inherits Stringable.
Public Member Functions | |
__toString () | |
getId () | |
Return the user ID. | |
getName () | |
Return the user name. | |
getToken () | |
Return the user token. | |
getUser () | |
Return a User object. | |
isAnon () | |
Return whether this is an anonymous user. | |
isVerified () | |
Return whether this represents a verified user. | |
verified () | |
Return a verified version of this object. | |
Static Public Member Functions | |
static | newAnonymous () |
Create an instance for an anonymous (i.e. | |
static | newFromId ( $id, $verified=false) |
Create an instance for a logged-in user by ID. | |
static | newFromName ( $name, $verified=false) |
Create an instance for a logged-in user by name. | |
static | newFromUser (User $user, $verified=false) |
Create an instance from an existing User object. | |
Object holding data about a session's user.
In general, this class exists for two purposes:
A UserInfo may be "verified". This indicates that the creator knows that the request really comes from that user, whether that's by validating OAuth credentials, SSL client certificates, or by having both the user ID and token available from cookies.
An "unverified" UserInfo should be used when it's not possible to authenticate the user, e.g. the user ID cookie is set but the user Token cookie isn't. If the Token is available but doesn't match, don't return a UserInfo at all.
Definition at line 55 of file UserInfo.php.
MediaWiki\Session\UserInfo::__toString | ( | ) |
Definition at line 186 of file UserInfo.php.
References MediaWiki\Session\UserInfo\getId(), MediaWiki\Session\UserInfo\getName(), and MediaWiki\Session\UserInfo\verified().
MediaWiki\Session\UserInfo::getId | ( | ) |
Return the user ID.
Definition at line 150 of file UserInfo.php.
Referenced by MediaWiki\Session\UserInfo\__toString().
MediaWiki\Session\UserInfo::getName | ( | ) |
Return the user name.
Definition at line 158 of file UserInfo.php.
Referenced by MediaWiki\Session\UserInfo\__toString().
MediaWiki\Session\UserInfo::getToken | ( | ) |
MediaWiki\Session\UserInfo::getUser | ( | ) |
Return a User object.
Definition at line 174 of file UserInfo.php.
References MediaWiki\MediaWikiServices\getInstance().
MediaWiki\Session\UserInfo::isAnon | ( | ) |
MediaWiki\Session\UserInfo::isVerified | ( | ) |
Return whether this represents a verified user.
Definition at line 141 of file UserInfo.php.
|
static |
Create an instance for an anonymous (i.e.
not logged in) user
Logged-out users are always "verified".
Definition at line 80 of file UserInfo.php.
Referenced by MediaWiki\Session\CookieSessionProvider\provideSessionInfo().
|
static |
Create an instance for a logged-in user by ID.
int | $id | User ID |
bool | $verified | True if the user is verified |
Definition at line 90 of file UserInfo.php.
References MediaWiki\MediaWikiServices\getInstance(), MediaWiki\User\User\isAnon(), MediaWiki\User\User\load(), and MediaWiki\User\User\newFromId().
Referenced by MediaWiki\Session\CookieSessionProvider\provideSessionInfo().
|
static |
Create an instance for a logged-in user by name.
string | $name | User name (need not exist locally) |
bool | $verified | True if the user is verified |
Definition at line 108 of file UserInfo.php.
References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\User\User\newFromName().
|
static |
Create an instance from an existing User object.
User | $user | (need not exist locally) |
bool | $verified | True if the user is verified |
Definition at line 125 of file UserInfo.php.
Referenced by MediaWiki\Session\BotPasswordSessionProvider\newSessionForRequest().
MediaWiki\Session\UserInfo::verified | ( | ) |
Return a verified version of this object.
Definition at line 182 of file UserInfo.php.
References MediaWiki\Session\UserInfo\verified().
Referenced by MediaWiki\Session\UserInfo\__toString(), and MediaWiki\Session\UserInfo\verified().