MediaWiki REL1_34
TOTPDisableForm.php
Go to the documentation of this file.
1<?php
2
4
7use Message;
9
14 public function onSuccess() {
15 $this->getOutput()->addWikiMsg( 'oathauth-disabledoath' );
16 }
17
18 protected function getDescriptors() {
19 return [
20 'token' => [
21 'type' => 'text',
22 'label-message' => 'oathauth-entertoken',
23 'name' => 'token',
24 'required' => true,
25 'autofocus' => true,
26 'dir' => 'ltr',
27 'autocomplete' => false,
28 'spellcheck' => false,
29 ]
30 ];
31 }
32
38 public function onSubmit( array $formData ) {
39 // Don't increase pingLimiter, just check for limit exceeded.
40 if ( $this->oathUser->getUser()->pingLimiter( 'badoath', 0 ) ) {
41 // Arbitrary duration given here
42 LoggerFactory::getInstance( 'authentication' )->info(
43 'OATHAuth {user} rate limited while disabling 2FA from {clientip}', [
44 'user' => $this->getUser()->getName(),
45 'clientip' => $this->getRequest()->getIP(),
46 ]
47 );
48 return [ 'oathauth-throttled', Message::durationParam( 60 ) ];
49 }
50
51 $module = $this->oathUser->getModule();
52 if ( $module instanceof TOTP ) {
53 if ( !$module->verify( $this->oathUser, [ 'token' => $formData['token'] ] ) ) {
54 LoggerFactory::getInstance( 'authentication' )->info(
55 'OATHAuth {user} failed to provide a correct token while disabling 2FA from {clientip}', [
56 'user' => $this->getUser()->getName(),
57 'clientip' => $this->getRequest()->getIP(),
58 ]
59 );
60 return [ 'oathauth-failedtovalidateoath' ];
61 }
62 }
63
64 $this->oathUser->setKeys();
65 $this->oathRepo->remove( $this->oathUser, $this->getRequest()->getIP() );
66
67 return true;
68 }
69}
MediaWiki exception.
onSuccess()
Add content to output when operation was successful.
PSR-3 logger instance factory.
The Message class provides methods which fulfil two basic services:
Definition Message.php:162
static durationParam( $duration)
Definition Message.php:1049
verify(OATHUser $user, array $data)
Run the validation.