$this->setHeaders();
$this->checkPermissions();
- // Make sure it's possible to log in
- if ( !$this->isSignup() && !$session->canSetUser() ) {
- throw new ErrorPageError( 'cannotloginnow-title', 'cannotloginnow-text', [
+ // Make sure the system configuration allows log in / sign up
+ if ( !$this->isSignup() && !$authManager->canAuthenticateNow() ) {
+ if ( !$session->canSetUser() ) {
+ throw new ErrorPageError( 'cannotloginnow-title', 'cannotloginnow-text', [
$session->getProvider()->describe( RequestContext::getMain()->getLanguage() )
] );
+ }
+ throw new ErrorPageError( 'cannotlogin-title', 'cannotlogin-text' );
+ } elseif ( $this->isSignup() && !$authManager->canCreateAccounts() ) {
+ throw new ErrorPageError( 'cannotcreateaccount-title', 'cannotcreateaccount-text' );
}
/*
$this->authAction = $this->isSignup() ? AuthManager::ACTION_CREATE_CONTINUE
: AuthManager::ACTION_LOGIN_CONTINUE;
$this->authRequests = $response->neededRequests;
- $this->mainLoginForm( $response->neededRequests, $response->message, 'warning' );
+ $this->mainLoginForm( $response->neededRequests, $response->message, $response->messageType );
break;
default:
throw new LogicException( 'invalid AuthenticationResponse' );
$form = $this->getAuthForm( $requests, $this->authAction, $msg, $msgtype );
$form->prepareForm();
- $formHtml = $form->getHTML( $msg ? Status::newFatal( $msg ) : false );
+
+ $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 ) );
}
$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;