Manual:Hooks/UserComparePasswords

From MediaWiki.org
Jump to navigation Jump to search
UserComparePasswords
Available from version 1.14.0 (r44815)
Removed in version 1.24. Use the Password Hashing API instead!
Called when checking passwords.
Define function:
public static function onUserComparePasswords( &$hash, &$password, &$userId, &$result ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"UserComparePasswords": "MyExtensionHooks::onUserComparePasswords"
	}
}

For MediaWiki ≤1.25:

$wgHooks['UserComparePasswords'][] = 'MyExtensionHooks::onUserComparePasswords';
Called from:File(s): User.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:UserComparePasswords extensions.

Details[edit]

Return false to override the default password checks.

  • &$hash: String of the password hash (from the database)
  • &$password: String of the plaintext password the user entered
  • &$userId: Integer of the user's ID or boolean false if the user ID was not supplied
  • &$result: If the hook returns false, this boolean value will be checked to determine if the password was valid