Show the first input as a warning, not as an error box

The first time the extension asks for the code of the mobile phone
isn't an error and shouldn't be styles as such (see the depends-on
change). Change all other UIs to errors.

Bug: T139179
Change-Id: I7cc3333c3e166295e85e91c7b377e53842bdb307
Depends-On: I9a27911613e62b5c4cb86bea40696cb37c4f49c2
This commit is contained in:
Florian 2016-07-26 18:57:11 +02:00
parent d2d3697633
commit 106497dc27

View file

@ -39,7 +39,7 @@ class TOTPSecondaryAuthenticationProvider extends AbstractSecondaryAuthenticatio
return AuthenticationResponse::newAbstain(); return AuthenticationResponse::newAbstain();
} else { } else {
return AuthenticationResponse::newUI( array( new TOTPAuthenticationRequest() ), return AuthenticationResponse::newUI( array( new TOTPAuthenticationRequest() ),
wfMessage( 'oathauth-auth-ui' ) ); wfMessage( 'oathauth-auth-ui' ), 'warning' );
} }
} }
@ -52,14 +52,17 @@ class TOTPSecondaryAuthenticationProvider extends AbstractSecondaryAuthenticatio
$request = AuthenticationRequest::getRequestByClass( $reqs, TOTPAuthenticationRequest::class ); $request = AuthenticationRequest::getRequestByClass( $reqs, TOTPAuthenticationRequest::class );
if ( !$request ) { if ( !$request ) {
return AuthenticationResponse::newUI( array( new TOTPAuthenticationRequest() ), return AuthenticationResponse::newUI( array( new TOTPAuthenticationRequest() ),
wfMessage( 'oathauth-login-failed' ) ); wfMessage( 'oathauth-login-failed' ), 'error' );
} }
$throttler = new Throttler( null, [ 'type' => 'TOTP' ] ); $throttler = new Throttler( null, [ 'type' => 'TOTP' ] );
$result = $throttler->increase( $user->getName(), null, __METHOD__ ); $result = $throttler->increase( $user->getName(), null, __METHOD__ );
if ( $result ) { if ( $result ) {
return AuthenticationResponse::newUI( array( new TOTPAuthenticationRequest() ), return AuthenticationResponse::newUI( array( new TOTPAuthenticationRequest() ),
new Message( 'oathauth-throttled', [ Message::durationParam( $result['wait'] ) ] ) ); new Message(
'oathauth-throttled',
[ Message::durationParam( $result['wait'] ) ]
), 'error' );
} }
$oathuser = OATHAuthHooks::getOATHUserRepository()->findByUser( $user ); $oathuser = OATHAuthHooks::getOATHUserRepository()->findByUser( $user );
@ -76,7 +79,7 @@ class TOTPSecondaryAuthenticationProvider extends AbstractSecondaryAuthenticatio
return AuthenticationResponse::newPass(); return AuthenticationResponse::newPass();
} else { } else {
return AuthenticationResponse::newUI( array( new TOTPAuthenticationRequest() ), return AuthenticationResponse::newUI( array( new TOTPAuthenticationRequest() ),
wfMessage( 'oathauth-login-failed' ) ); wfMessage( 'oathauth-login-failed' ), 'error' );
} }
} }