From afeef98df2dc63487a1fef9f124a8d1dfc7cdef5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sat, 17 Sep 2016 16:24:34 +0200 Subject: [PATCH] LoginSignupSpecialPage: Reduce hackiness of "You are already logged in" warning Use HTMLForm's built-in error/warning handling, rather than generate the HTML ourselves. Depends on I9a27911613e62b5c4cb86bea40696cb37c4f49c2. Change-Id: I80dd9dfcd546a50479ebe07b267105cfd4677fc7 --- includes/specialpage/LoginSignupSpecialPage.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/includes/specialpage/LoginSignupSpecialPage.php b/includes/specialpage/LoginSignupSpecialPage.php index 9e9397017c..e83c5cf5c6 100644 --- a/includes/specialpage/LoginSignupSpecialPage.php +++ b/includes/specialpage/LoginSignupSpecialPage.php @@ -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; -- 2.20.1