* returned success.
*
* @param AuthenticationRequest $req
+ * @param bool $isAddition Set true if this represents an addition of
+ * credentials rather than a change. The main difference is that additions
+ * should not invalidate BotPasswords. If you're not sure, leave it false.
*/
- public function changeAuthenticationData( AuthenticationRequest $req ) {
+ public function changeAuthenticationData( AuthenticationRequest $req, $isAddition = false ) {
$this->logger->info( 'Changing authentication data for {user} class {what}', [
'user' => is_string( $req->username ) ? $req->username : '<no name>',
'what' => get_class( $req ),
// When the main account's authentication data is changed, invalidate
// all BotPasswords too.
- \BotPassword::invalidateAllPasswordsForUser( $req->username );
+ if ( !$isAddition ) {
+ \BotPassword::invalidateAllPasswordsForUser( $req->username );
+ }
}
/**@}*/
* Fetch authentication data from the current session
* @protected For use by AuthenticationProviders
* @param string $key
- * @param mixed $default
+ * @param mixed|null $default
* @return mixed
*/
public function getAuthenticationSessionData( $key, $default = null ) {
* @param bool $useContextLang Use 'uselang' to set the user's language
*/
private function setDefaultUserOptions( User $user, $useContextLang ) {
- global $wgContLang;
-
$user->setToken();
- $lang = $useContextLang ? \RequestContext::getMain()->getLanguage() : $wgContLang;
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+
+ $lang = $useContextLang ? \RequestContext::getMain()->getLanguage() : $contLang;
$user->setOption( 'language', $lang->getPreferredVariant() );
- if ( $wgContLang->hasVariants() ) {
- $user->setOption( 'variant', $wgContLang->getPreferredVariant() );
+ if ( $contLang->hasVariants() ) {
+ $user->setOption( 'variant', $contLang->getPreferredVariant() );
}
}