31 if (
$params[
'user'] ===
null ) {
38 if ( $user ===
false ) {
43 if ( $user->pingLimiter(
'badoath', 0 ) ) {
53 if ( !$user->isAnon() ) {
55 ->findByUser( $user );
57 $key = $oathUser->getKey();
58 if ( $key !==
null ) {
59 $result[
'enabled'] =
true;
60 $result[
'valid'] = $key->verifyToken(
61 $params[
'totp'], $oathUser ) !==
false;
95 'action=oathvalidate&totp=123456&token=123ABC'
96 =>
'apihelp-oathvalidate-example-1',
97 'action=oathvalidate&user=Example&totp=123456&token=123ABC'
98 =>
'apihelp-oathvalidate-example-2',
This abstract class implements many basic API functions, and is the base of all API classes.
const PARAM_REQUIRED
(boolean) Is the parameter required?
checkUserRightsAny( $rights, $user=null)
Helper function for permission-denied errors.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
requirePostedParameters( $params, $prefix='prefix')
Die if any of the specified parameters were found in the query part of the URL rather than the post b...
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModuleName()
Get the name of the module being executed by this instance.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
getExamplesMessages()
Returns usage examples for this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
needsToken()
Returns the token type this module requires in order to execute.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
isInternal()
Indicates whether this module is "internal" Internal API modules are not (yet) intended for 3rd party...
const META_BC_BOOLS
Key for the 'BC bools' metadata item.
static getOATHUserRepository()
Get the singleton OATH user repository.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.