mediawiki-extensions-OATHAuth/OATHUser.php
Reedy 872a4768ff Allow override of Site prefix without changing sitename
Bug: T147901
Change-Id: Id5b565f9c05b591e3638dbf51dd784224203669c
2016-10-31 14:17:27 +00:00

61 lines
1 KiB
PHP

<?php
/**
* Class representing a user from OATH's perspective
*
* @ingroup Extensions
*/
class OATHUser {
/** @var User */
private $user;
/** @var OATHAuthKey|null */
private $key;
/**
* @param User $user
* @param OATHAuthKey $key
*/
public function __construct( User $user, OATHAuthKey $key = null ) {
$this->user = $user;
$this->key = $key;
}
/**
* @return User
*/
public function getUser() {
return $this->user;
}
/**
* @return String
*/
public function getAccount() {
global $wgSitename, $wgOATHAuthAccountPrefix;
if ( $wgOATHAuthAccountPrefix !== false ) {
return "$wgOATHAuthAccountPrefix:{$this->user->getName()}";
}
return "$wgSitename:{$this->user->getName()}";
}
/**
* Get the key associated with this user.
*
* @return null|OATHAuthKey
*/
public function getKey() {
return $this->key;
}
/**
* Set the key associated with this user.
*
* @param OATHAuthKey|null $key
*/
public function setKey( OATHAuthKey $key = null ) {
$this->key = $key;
}
}