X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecialpage%2FLoginSignupSpecialPage.php;h=d3cd5777c6c879dcc22572e4b91b2bfed662fd8b;hb=f7cfed2a4a67264e5a76773246d155449ba5e186;hp=bf83e7bb37f5ab4874db26a31497d6ca48cdcc6c;hpb=17914cc990c375340b688900b7782f1d7d5339fc;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specialpage/LoginSignupSpecialPage.php b/includes/specialpage/LoginSignupSpecialPage.php index bf83e7bb37..d3cd5777c6 100644 --- a/includes/specialpage/LoginSignupSpecialPage.php +++ b/includes/specialpage/LoginSignupSpecialPage.php @@ -294,6 +294,14 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { return; } + if ( $this->canBypassForm( $button_name ) ) { + $this->setRequest( [], true ); + $this->getRequest()->setVal( $this->getTokenName(), $this->getToken() ); + if ( $button_name ) { + $this->getRequest()->setVal( $button_name, true ); + } + } + $status = $this->trySubmit(); if ( !$status || !$status->isGood() ) { @@ -366,6 +374,46 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage { } } + /** + * Determine if the login form can be bypassed. This will be the case when no more than one + * button is present and no other user input fields that are not marked as 'skippable' are + * present. If the login form were not bypassed, the user would be presented with a + * superfluous page on which they must press the single button to proceed with login. + * Not only does this cause an additional mouse click and page load, it confuses users, + * especially since there are a help link and forgotten password link that are + * provided on the login page that do not apply to this situation. + * + * @param string|null &$button_name if the form has a single button, returns + * the name of the button; otherwise, returns null + * @return bool + */ + private function canBypassForm( &$button_name ) { + $button_name = null; + if ( $this->isContinued() ) { + return false; + } + $fields = AuthenticationRequest::mergeFieldInfo( $this->authRequests ); + foreach ( $fields as $fieldname => $field ) { + if ( !isset( $field['type'] ) ) { + return false; + } + if ( !empty( $field['skippable'] ) ) { + continue; + } + if ( $field['type'] === 'button' ) { + if ( $button_name !== null ) { + $button_name = null; + return false; + } else { + $button_name = $fieldname; + } + } elseif ( $field['type'] !== 'null' ) { + return false; + } + } + return true; + } + /** * Show the success page. *