42 private $loadBalancer;
52 parent::__construct( $params );
53 $this->loginOnly = !empty( $params[
'loginOnly'] );
54 $this->loadBalancer = $loadBalancer;
67 if ( $expiration ===
null || (
int)$expiration >= $now ) {
72 if ( (
int)$expiration + $grace < $now ) {
75 'msg' => \Status::newFatal(
'resetpass-expired' )->getMessage(),
80 'msg' => \Status::newFatal(
'resetpass-expired-soft' )->getMessage(),
93 if ( $req->username ===
null || $req->password ===
null ) {
97 $username = $this->userNameUtils->getCanonical(
98 $req->username, UserRigorOptions::RIGOR_USABLE );
99 if ( $username ===
false ) {
104 'user_id',
'user_password',
'user_password_expires',
108 $row =
$dbr->selectRow(
111 [
'user_name' => $username ],
121 $oldRow = clone $row;
124 if ( preg_match(
'/^[0-9a-f]{32}$/', $row->user_password ) ) {
125 $row->user_password =
":B:{$row->user_id}:{$row->user_password}";
129 if ( !$status->isOK() ) {
134 $pwhash = $this->
getPassword( $row->user_password );
135 if ( !$pwhash->verify( $req->password ) ) {
139 $cp1252Password = iconv(
'UTF-8',
'WINDOWS-1252//TRANSLIT', $req->password );
140 if ( $cp1252Password === $req->password || !$pwhash->verify( $cp1252Password ) ) {
152 \DeferredUpdates::addCallableUpdate(
function () use ( $newHash, $oldRow, $fname ) {
153 $dbw = $this->loadBalancer->getConnectionRef(
DB_PRIMARY );
156 [
'user_password' => $newHash->toString() ],
158 'user_id' => $oldRow->user_id,
159 'user_password' => $oldRow->user_password
173 $username = $this->userNameUtils->getCanonical(
174 $username, UserRigorOptions::RIGOR_USABLE );
175 if ( $username ===
false ) {
180 $row =
$dbr->selectRow(
183 [
'user_name' => $username ],
192 if ( preg_match(
'/^[0-9a-f]{32}$/', $row->user_password ) ) {
196 return !$this->
getPassword( $row->user_password ) instanceof \InvalidPassword;
200 $username = $this->userNameUtils->getCanonical(
201 $username, UserRigorOptions::RIGOR_USABLE );
202 if ( $username ===
false ) {
206 list( $db, $options ) = \DBAccessObjectUtils::getDBOptions( $flags );
207 return (
bool)$this->loadBalancer->getConnectionRef( $db )->selectField(
210 [
'user_name' => $username ],
221 if ( $this->loginOnly ) {
222 return \StatusValue::newGood(
'ignored' );
225 if ( get_class( $req ) === PasswordAuthenticationRequest::class ) {
227 return \StatusValue::newGood();
230 $username = $this->userNameUtils->getCanonical( $req->username,
231 UserRigorOptions::RIGOR_USABLE );
232 if ( $username !==
false ) {
233 $row = $this->loadBalancer->getConnectionRef(
DB_PRIMARY )->selectRow(
236 [
'user_name' => $username ],
240 $sv = \StatusValue::newGood();
241 if ( $req->password !==
null ) {
242 if ( $req->password !== $req->retype ) {
243 $sv->fatal(
'badretype' );
253 return \StatusValue::newGood(
'ignored' );
257 $username = $req->username !==
null ?
258 $this->userNameUtils->getCanonical( $req->username, UserRigorOptions::RIGOR_USABLE )
260 if ( $username ===
false ) {
266 if ( get_class( $req ) === PasswordAuthenticationRequest::class ) {
267 if ( $this->loginOnly ) {
277 $dbw = $this->loadBalancer->getConnectionRef(
DB_PRIMARY );
281 'user_password' => $pwhash->toString(),
283 'user_password_expires' => $dbw->timestampOrNull( $expiry ),
285 [
'user_name' => $username ],
298 $ret = \StatusValue::newGood();
299 if ( !$this->loginOnly && $req && $req->username !==
null && $req->password !==
null ) {
300 if ( $req->password !== $req->retype ) {
301 $ret->fatal(
'badretype' );
313 throw new \BadMethodCallException(
'Shouldn\'t call this when accountCreationType() is NONE' );
317 if ( $req && $req->username !==
null && $req->password !==
null ) {
320 if ( $req->username !== $user->getName() ) {
322 $req->username = $user->getName();
325 $ret->createRequest = $req;
333 throw new \BadMethodCallException(
'Shouldn\'t call this when accountCreationType() is NONE' );
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
A class containing constants representing the names of configuration variables.
const LegacyEncoding
Name constant for the LegacyEncoding setting, for use with Config::get()
const PasswordExpireGrace
Name constant for the PasswordExpireGrace setting, for use with Config::get()