X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecialpage%2FAuthManagerSpecialPage.php;h=bdf76384c8e6ecd2e513ced019c19f0da7dc16a7;hb=645266fe3e1befe84b800b4f78a3b208fa8943d4;hp=68f0d00ddbfa9308efdd37f7e2a79219b861d700;hpb=abb4d29b54c1bc4b4fb620f1124559ead13a074e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specialpage/AuthManagerSpecialPage.php b/includes/specialpage/AuthManagerSpecialPage.php index 68f0d00ddb..bdf76384c8 100644 --- a/includes/specialpage/AuthManagerSpecialPage.php +++ b/includes/specialpage/AuthManagerSpecialPage.php @@ -43,7 +43,7 @@ abstract class AuthManagerSpecialPage extends SpecialPage { * Change the form descriptor that determines how a field will look in the authentication form. * Called from fieldInfoToFormDescriptor(). * @param AuthenticationRequest[] $requests - * @param string $fieldInfo Field information array (union of all + * @param array $fieldInfo Field information array (union of all * AuthenticationRequest::getFieldInfo() responses). * @param array $formDescriptor HTMLForm descriptor. The special key 'weight' can be set to * change the order of the fields. @@ -205,6 +205,7 @@ abstract class AuthManagerSpecialPage extends SpecialPage { /** * Return custom message key. * Allows subclasses to customize messages. + * @param string $defaultKey * @return string */ protected function messageKey( $defaultKey ) { @@ -554,38 +555,46 @@ abstract class AuthManagerSpecialPage extends SpecialPage { } /** - * Returns true if the form built from the given AuthenticationRequests has fields which take - * values. If all available providers use the redirect flow, the form might contain nothing - * but submit buttons, in which case we should not add an extra submit button which does nothing. + * Returns true if the form built from the given AuthenticationRequests needs a submit button. + * Providers using redirect flow (e.g. Google login) need their own submit buttons; if using + * one of those custom buttons is the only way to proceed, there is no point in displaying the + * default button which won't do anything useful. * * @param AuthenticationRequest[] $requests An array of AuthenticationRequests from which the * form will be built * @return bool */ protected function needsSubmitButton( array $requests ) { + $customSubmitButtonPresent = false; + + // Secondary and preauth providers always need their data; they will not care what button + // is used, so they can be ignored. So can OPTIONAL buttons createdby primary providers; + // that's the point in being optional. Se we need to check whether all primary providers + // have their own buttons and whether there is at least one button present. foreach ( $requests as $req ) { - if ( $req->required === AuthenticationRequest::PRIMARY_REQUIRED && - $this->doesRequestNeedsSubmitButton( $req ) - ) { - return true; + if ( $req->required === AuthenticationRequest::PRIMARY_REQUIRED ) { + if ( $this->hasOwnSubmitButton( $req ) ) { + $customSubmitButtonPresent = true; + } else { + return true; + } } } - return false; + return !$customSubmitButtonPresent; } /** - * Checks if the given AuthenticationRequest needs a submit button or not. - * - * @param AuthenticationRequest $req The request to check + * Checks whether the given AuthenticationRequest has its own submit button. + * @param AuthenticationRequest $req * @return bool */ - protected function doesRequestNeedsSubmitButton( AuthenticationRequest $req ) { + protected function hasOwnSubmitButton( AuthenticationRequest $req ) { foreach ( $req->getFieldInfo() as $field => $info ) { if ( $info['type'] === 'button' ) { - return false; + return true; } } - return true; + return false; } /** @@ -660,6 +669,7 @@ abstract class AuthManagerSpecialPage extends SpecialPage { * Maps an authentication field configuration for a single field (as returned by * AuthenticationRequest::getFieldInfo()) to a HTMLForm field descriptor. * @param array $singleFieldInfo + * @param string $fieldName * @return array */ protected static function mapSingleFieldInfo( $singleFieldInfo, $fieldName ) {