2012-05-07 21:54:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class representing a user from OATH's perspective
|
|
|
|
*
|
|
|
|
* @ingroup Extensions
|
|
|
|
*/
|
|
|
|
class OATHUser {
|
2014-05-19 00:05:59 +00:00
|
|
|
/** @var User */
|
|
|
|
private $user;
|
2014-05-11 08:16:03 +00:00
|
|
|
|
2014-05-19 00:05:59 +00:00
|
|
|
/** @var OATHAuthKey|null */
|
|
|
|
private $key;
|
2012-05-07 21:54:44 +00:00
|
|
|
|
|
|
|
/**
|
2016-06-15 10:07:01 +00:00
|
|
|
* Constructor. Can't be called directly. Use OATHUserRepository::findByUser instead.
|
2014-05-19 00:05:59 +00:00
|
|
|
* @param User $user
|
2018-04-05 11:27:13 +00:00
|
|
|
* @param OATHAuthKey|null $key
|
2012-05-07 21:54:44 +00:00
|
|
|
*/
|
2014-05-19 00:05:59 +00:00
|
|
|
public function __construct( User $user, OATHAuthKey $key = null ) {
|
|
|
|
$this->user = $user;
|
|
|
|
$this->key = $key;
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
|
|
|
|
2016-09-16 23:18:35 +00:00
|
|
|
/**
|
|
|
|
* @return User
|
|
|
|
*/
|
2014-05-19 00:05:59 +00:00
|
|
|
public function getUser() {
|
|
|
|
return $this->user;
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return String
|
|
|
|
*/
|
2016-11-13 03:43:55 +00:00
|
|
|
public function getIssuer() {
|
2016-10-31 14:17:27 +00:00
|
|
|
global $wgSitename, $wgOATHAuthAccountPrefix;
|
|
|
|
if ( $wgOATHAuthAccountPrefix !== false ) {
|
2016-11-13 03:43:55 +00:00
|
|
|
return $wgOATHAuthAccountPrefix;
|
2016-10-31 14:17:27 +00:00
|
|
|
}
|
2016-11-13 03:43:55 +00:00
|
|
|
return $wgSitename;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return String
|
|
|
|
*/
|
|
|
|
public function getAccount() {
|
|
|
|
return $this->user->getName();
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-19 00:05:59 +00:00
|
|
|
* Get the key associated with this user.
|
|
|
|
*
|
|
|
|
* @return null|OATHAuthKey
|
2012-05-07 21:54:44 +00:00
|
|
|
*/
|
2014-05-19 00:05:59 +00:00
|
|
|
public function getKey() {
|
|
|
|
return $this->key;
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-19 00:05:59 +00:00
|
|
|
* Set the key associated with this user.
|
|
|
|
*
|
|
|
|
* @param OATHAuthKey|null $key
|
2012-05-07 21:54:44 +00:00
|
|
|
*/
|
2014-05-19 00:05:59 +00:00
|
|
|
public function setKey( OATHAuthKey $key = null ) {
|
|
|
|
$this->key = $key;
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
|
|
|
}
|