Manual:Hooks/AbortLogin

From MediaWiki.org
Jump to navigation Jump to search
AbortLogin
Available from version 1.11.0
Removed in version 1.33.0
Can cancel the login process
Define function:
public static function onAbortLogin( User $user, $password, LoginForm &$retVal, &$msg ) { ... }
Attach hook:

In extension.json:

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

For MediaWiki ≤1.25:

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

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

Details[edit]

  • $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 (introduced in 1.18)

Notes[edit]

  • 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.