Open main menu

Manual:Hooks/AbortLogin

< Manual:Hooks
AbortLogin
Available from version 1.11.0
Removed in version 1.33
Can cancel the login process
Define function:
public static function onAbortLogin( $user, $password, &$retval, &$msg ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"AbortLogin": "MyExtensionHooks::onAbortLogin"
	}
}

For MediaWiki ≤1.25:

$wgHooks['AbortLogin'][] = 'MyExtensionHooks::onAbortLogin';
Called from:File(s): SpecialUserlogin.php

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

DetailsEdit

  • $user: User object being authenticated against
  • $password: password being submitted (before validity checks)
  • &$retval: a LoginForm class constant to return from authenticateUserData (default is LoginForm::ABORTED)
  • &$msg: name of the error message displayed to the user (MediaWiki 1.18+)

NotesEdit

  • Can be used to allow an extension (for example, a captcha) to abort the login process
  • For &$retval, note that client may be using a machine API rather than the HTML user interface.

DeprecatedEdit

From MediaWiki 1.27 on, the hook is deprecated and superseded by AuthManager functionality. Any logic in it should probably be moved to a class implementing PreAuthenticationProvider, into the testForAuthentication method.