mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/OATHAuth
synced 2024-11-24 08:14:15 +00:00
Define fallback for request IP when persisting user
Bug: T237554 Change-Id: I18f57a523a6515f593963a9c149374bd6f6c73b4
This commit is contained in:
parent
0a7729a578
commit
54fc8a0cbf
|
@ -22,6 +22,7 @@ namespace MediaWiki\Extension\OATHAuth\Key;
|
|||
use Base32\Base32;
|
||||
use jakobo\HOTP\HOTP;
|
||||
use MediaWiki\Extension\OATHAuth\OATHUser;
|
||||
use MediaWiki\Extension\OATHAuth\OATHUserRepository;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use DomainException;
|
||||
|
@ -195,6 +196,8 @@ class TOTPKey implements IAuthKey {
|
|||
|
||||
$auth = MediaWikiServices::getInstance()->getService( 'OATHAuth' );
|
||||
$module = $auth->getModuleByKey( 'totp' );
|
||||
|
||||
/** @var OATHUserRepository $userRepo */
|
||||
$userRepo = MediaWikiServices::getInstance()->getService( 'OATHUserRepository' );
|
||||
$user->addKey( $this );
|
||||
$user->setModule( $module );
|
||||
|
|
|
@ -29,6 +29,7 @@ use BagOStuff;
|
|||
use ConfigException;
|
||||
use User;
|
||||
use stdClass;
|
||||
use RequestContext;
|
||||
|
||||
class OATHUserRepository {
|
||||
/** @var ILoadBalancer */
|
||||
|
@ -119,11 +120,14 @@ class OATHUserRepository {
|
|||
|
||||
/**
|
||||
* @param OATHUser $user
|
||||
* @param string $clientInfo
|
||||
* @param string|null $clientInfo
|
||||
* @throws ConfigException
|
||||
* @throws MWException
|
||||
*/
|
||||
public function persist( OATHUser $user, $clientInfo ) {
|
||||
public function persist( OATHUser $user, $clientInfo = null ) {
|
||||
if ( !$clientInfo ) {
|
||||
$clientInfo = RequestContext::getMain()->getRequest()->getIP();
|
||||
}
|
||||
$prevUser = $this->findByUser( $user->getUser() );
|
||||
$data = $user->getModule()->getDataFromUser( $user );
|
||||
|
||||
|
|
Loading…
Reference in a new issue