Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4091992
TOTPDisableForm.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
TOTPDisableForm.php
View Options
<?php
namespace
MediaWiki\Extension\OATHAuth\HTMLForm
;
use
MediaWiki\Extension\OATHAuth\Key\TOTPKey
;
use
MediaWiki\Logger\LoggerFactory
;
use
MediaWiki\Message\Message
;
use
MWException
;
class
TOTPDisableForm
extends
OATHAuthOOUIHTMLForm
{
/**
* Add content to output when operation was successful
*/
public
function
onSuccess
()
{
$this
->
getOutput
()->
addWikiMsg
(
'oathauth-disabledoath'
);
}
/**
* @return array
*/
protected
function
getDescriptors
()
{
return
[
'token'
=>
[
'type'
=>
'text'
,
'label-message'
=>
'oathauth-entertoken'
,
'name'
=>
'token'
,
'required'
=>
true
,
'autofocus'
=>
true
,
'dir'
=>
'ltr'
,
'autocomplete'
=>
'one-time-code'
,
'spellcheck'
=>
false
,
'help'
=>
$this
->
msg
(
'oathauth-hint'
)->
parse
(),
],
];
}
/**
* @param array $formData
* @return array|bool
* @throws MWException
*/
public
function
onSubmit
(
array
$formData
)
{
// Don't increase pingLimiter, instead check for the limit being exceeded.
if
(
$this
->
oathUser
->
getUser
()->
pingLimiter
(
'badoath'
,
0
)
)
{
// Arbitrary duration given here
LoggerFactory
::
getInstance
(
'authentication'
)->
info
(
'OATHAuth {user} rate limited while disabling 2FA from {clientip}'
,
[
'user'
=>
$this
->
getUser
()->
getName
(),
'clientip'
=>
$this
->
getRequest
()->
getIP
(),
]
);
return
[
'oathauth-throttled'
,
Message
::
durationParam
(
60
)
];
}
foreach
(
$this
->
oathUser
->
getKeys
()
as
$key
)
{
if
(
!(
$key
instanceof
TOTPKey
)
)
{
continue
;
}
if
(
!
$key
->
verify
(
[
'token'
=>
$formData
[
'token'
]
],
$this
->
oathUser
)
)
{
continue
;
}
$this
->
oathRepo
->
removeKey
(
$this
->
oathUser
,
$key
,
$this
->
getRequest
()->
getIP
(),
true
);
return
true
;
}
LoggerFactory
::
getInstance
(
'authentication'
)->
info
(
'OATHAuth {user} failed to provide a correct token while disabling 2FA from {clientip}'
,
[
'user'
=>
$this
->
getUser
()->
getName
(),
'clientip'
=>
$this
->
getRequest
()->
getIP
(),
]
);
// Increase rate limit counter for failed request
$this
->
getUser
()->
pingLimiter
(
'badoath'
);
return
[
'oathauth-failedtovalidateoath'
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 18 2026, 12:00 (4 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
96/dc/ae061ed7ed0d700d8dd9ee8a8212
Default Alt Text
TOTPDisableForm.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment