mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/OATHAuth
synced 2024-11-24 00:05:24 +00:00
Update for API error i18n
See Iae0e2ce3. Change-Id: Ie30549363b079ea23d6eab5959d10ada8f74acdf
This commit is contained in:
parent
22afe69466
commit
47d7c04496
|
@ -32,21 +32,16 @@ class ApiOATHValidate extends ApiBase {
|
|||
$params['user'] = $this->getUser()->getName();
|
||||
}
|
||||
|
||||
if ( !$this->getUser()->isAllowed( 'oathauth-api-all' ) ) {
|
||||
$this->dieUsage(
|
||||
'You do not have permission to validate an OATH token',
|
||||
'permissiondenied'
|
||||
);
|
||||
}
|
||||
$this->checkUserRightsAny( 'oathauth-api-all' );
|
||||
|
||||
$user = User::newFromName( $params['user'] );
|
||||
if ( $user === false ) {
|
||||
$this->dieUsageMsg( [ 'noname', $params['user'] ] );
|
||||
$this->dieWithError( 'noname' );
|
||||
}
|
||||
|
||||
// Don't increase pingLimiter, just check for limit exceeded.
|
||||
if ( $user->pingLimiter( 'badoath', 0 ) ) {
|
||||
$this->dieUsageMsg( 'actionthrottledtext' );
|
||||
$this->dieWithError( 'apierror-ratelimited' );
|
||||
}
|
||||
|
||||
$result = [
|
||||
|
|
|
@ -37,16 +37,11 @@ class ApiQueryOATH extends ApiQueryBase {
|
|||
$params['user'] = $this->getUser()->getName();
|
||||
}
|
||||
|
||||
if ( !$this->getUser()->isAllowed( 'oathauth-api-all' ) ) {
|
||||
$this->dieUsage(
|
||||
'You do not have permission to check OATH status',
|
||||
'permissiondenied'
|
||||
);
|
||||
}
|
||||
$this->checkUserRightsAny( 'oathauth-api-all' );
|
||||
|
||||
$user = User::newFromName( $params['user'] );
|
||||
if ( $user === false ) {
|
||||
$this->dieUsageMsg( [ 'noname', $params['user'] ] );
|
||||
$this->dieWithError( 'noname' );
|
||||
}
|
||||
|
||||
$result = $this->getResult();
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
"grant-group-authentication": "Perform authentication actions for self and others",
|
||||
"grant-oath": "Access two-factor authentication (OATH) information for self and others",
|
||||
"right-oathauth-api-all": "Query and validate OATH information for self and others",
|
||||
"action-oathauth-api-all": "check OATH status",
|
||||
"apihelp-query+oath-description": "Check to see if two-factor authentication (OATH) is enabled for a user.",
|
||||
"apihelp-query+oath-param-user": "User to get information about. Defaults to the current user.",
|
||||
"apihelp-query+oath-example-1": "Get information about the current user",
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
"grant-group-authentication": "{{Related|Grant-group}}",
|
||||
"grant-oath": "Name for grant \"oath\".\n{{Related|Grant}}",
|
||||
"right-oathauth-api-all": "{{doc-right|oathauth-api-all}}",
|
||||
"action-oathauth-api-all": "{{doc-action|oathauth-api-all}}",
|
||||
"apihelp-query+oath-description": "{{doc-apihelp-description|query+oath}}",
|
||||
"apihelp-query+oath-param-user": "{{doc-apihelp-param|query+oath|user}}",
|
||||
"apihelp-query+oath-example-1": "{{doc-apihelp-example|query+oath}}",
|
||||
|
|
Loading…
Reference in a new issue