|
@@ 1157-1163 (lines=7) @@
|
| 1154 |
|
// Step 0: Prepare and validate the input |
| 1155 |
|
|
| 1156 |
|
$user = User::newFromName( $state['username'], 'creatable' ); |
| 1157 |
|
if ( !is_object( $user ) ) { |
| 1158 |
|
$session->remove( 'AuthManager::accountCreationState' ); |
| 1159 |
|
$this->logger->debug( __METHOD__ . ': Invalid username', [ |
| 1160 |
|
'user' => $state['username'], |
| 1161 |
|
] ); |
| 1162 |
|
return AuthenticationResponse::newFail( wfMessage( 'noname' ) ); |
| 1163 |
|
} |
| 1164 |
|
|
| 1165 |
|
if ( $state['creatorid'] ) { |
| 1166 |
|
$creator = User::newFromId( $state['creatorid'] ); |
|
@@ 1175-1183 (lines=9) @@
|
| 1172 |
|
// Avoid account creation races on double submissions |
| 1173 |
|
$cache = \ObjectCache::getLocalClusterInstance(); |
| 1174 |
|
$lock = $cache->getScopedLock( $cache->makeGlobalKey( 'account', md5( $user->getName() ) ) ); |
| 1175 |
|
if ( !$lock ) { |
| 1176 |
|
// Don't clear AuthManager::accountCreationState for this code |
| 1177 |
|
// path because the process that won the race owns it. |
| 1178 |
|
$this->logger->debug( __METHOD__ . ': Could not acquire account creation lock', [ |
| 1179 |
|
'user' => $user->getName(), |
| 1180 |
|
'creator' => $creator->getName(), |
| 1181 |
|
] ); |
| 1182 |
|
return AuthenticationResponse::newFail( wfMessage( 'usernameinprogress' ) ); |
| 1183 |
|
} |
| 1184 |
|
|
| 1185 |
|
// Permissions check |
| 1186 |
|
$status = $this->checkAccountCreatePermissions( $creator ); |