LoginSignupSpecialPage: Reduce hackiness of "You are already logged in" warning
authorBartosz Dziewoński <matma.rex@gmail.com>
Sat, 17 Sep 2016 14:24:34 +0000 (16:24 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sat, 17 Sep 2016 14:33:40 +0000 (16:33 +0200)
Use HTMLForm's built-in error/warning handling, rather than generate
the HTML ourselves. Depends on I9a27911613e62b5c4cb86bea40696cb37c4f49c2.

Change-Id: I80dd9dfcd546a50479ebe07b267105cfd4677fc7

includes/specialpage/LoginSignupSpecialPage.php

index 9e93970..e83c5cf 100644 (file)
@@ -494,12 +494,20 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
 
                $form = $this->getAuthForm( $requests, $this->authAction, $msg, $msgtype );
                $form->prepareForm();
+
                $submitStatus = Status::newGood();
                if ( $msg && $msgtype === 'warning' ) {
                        $submitStatus->warning( $msg );
                } elseif ( $msg && $msgtype === 'error' ) {
                        $submitStatus->fatal( $msg );
                }
+
+               // warning header for non-standard workflows (e.g. security reauthentication)
+               if ( !$this->isSignup() && $this->getUser()->isLoggedIn() ) {
+                       $reauthMessage = $this->securityLevel ? 'userlogin-reauth' : 'userlogin-loggedin';
+                       $submitStatus->warning( $reauthMessage, $this->getUser()->getName() );
+               }
+
                $formHtml = $form->getHTML( $submitStatus );
 
                $out->addHTML( $this->getPageHtml( $formHtml ) );
@@ -622,13 +630,6 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
                        $form->setId( 'userlogin2' );
                }
 
-               // warning header for non-standard workflows (e.g. security reauthentication)
-               if ( !$this->isSignup() && $this->getUser()->isLoggedIn() ) {
-                       $reauthMessage = $this->securityLevel ? 'userlogin-reauth' : 'userlogin-loggedin';
-                       $form->addHeaderText( Html::rawElement( 'div', [ 'class' => 'warningbox' ],
-                               $this->msg( $reauthMessage )->params( $this->getUser()->getName() )->parse() ) );
-               }
-
                $form->suppressDefaultSubmit();
 
                $this->authForm = $form;