45 parent::__construct( $params );
46 $this->loginOnly = !empty( $params[
'loginOnly'] );
59 if ( $expiration ===
null || $expiration >= $now ) {
63 $grace = $this->config->get(
'PasswordExpireGrace' );
64 if ( $expiration + $grace < $now ) {
85 if ( $req->username ===
null || $req->password ===
null ) {
90 if ( $username ===
false ) {
95 'user_id',
'user_password',
'user_password_expires',
99 $row =
$dbr->selectRow(
102 [
'user_name' => $username ],
112 $oldRow = clone $row;
115 if ( preg_match(
'/^[0-9a-f]{32}$/', $row->user_password ) ) {
116 $row->user_password =
":B:{$row->user_id}:{$row->user_password}";
125 $pwhash = $this->
getPassword( $row->user_password );
126 if ( !$pwhash->verify( $req->password ) ) {
127 if ( $this->config->get(
'LegacyEncoding' ) ) {
130 $cp1252Password = iconv(
'UTF-8',
'WINDOWS-1252//TRANSLIT', $req->password );
131 if ( $cp1252Password === $req->password || !$pwhash->verify( $cp1252Password ) ) {
147 [
'user_password' => $newHash->toString() ],
149 'user_id' => $oldRow->user_id,
150 'user_password' => $oldRow->user_password
165 if ( $username ===
false ) {
170 $row =
$dbr->selectRow(
173 [
'user_name' => $username ],
182 if ( preg_match(
'/^[0-9a-f]{32}$/', $row->user_password ) ) {
186 return !$this->
getPassword( $row->user_password ) instanceof \InvalidPassword;
191 if ( $username ===
false ) {
196 return (
bool)
wfGetDB( $db )->selectField(
199 [
'user_name' => $username ],
210 if ( $this->loginOnly ) {
211 return \StatusValue::newGood(
'ignored' );
214 if ( get_class( $req ) === PasswordAuthenticationRequest::class ) {
216 return \StatusValue::newGood();
220 if ( $username !==
false ) {
224 [
'user_name' => $username ],
229 if ( $req->password !==
null ) {
230 if ( $req->password !== $req->retype ) {
231 $sv->fatal(
'badretype' );
241 return \StatusValue::newGood(
'ignored' );
246 if ( $username ===
false ) {
252 if ( get_class( $req ) === PasswordAuthenticationRequest::class ) {
253 if ( $this->loginOnly ) {
267 'user_password' => $pwhash->toString(),
268 'user_password_expires' => $dbw->timestampOrNull( $expiry ),
270 [
'user_name' => $username ],
284 if ( !$this->loginOnly && $req && $req->username !==
null && $req->password !==
null ) {
285 if ( $req->password !== $req->retype ) {
286 $ret->fatal(
'badretype' );
298 throw new \BadMethodCallException(
'Shouldn\'t call this when accountCreationType() is NONE' );
302 if ( $req && $req->username !==
null && $req->password !==
null ) {
305 if ( $req->username !== $user->getName() ) {
307 $req->username = $user->getName();
310 $ret->createRequest = $req;
318 throw new \BadMethodCallException(
'Shouldn\'t call this when accountCreationType() is NONE' );