N°2311 - Login Page extensibility

This commit is contained in:
Eric
2019-09-06 17:40:29 +02:00
parent 20aa1bfdd6
commit ee621c1b92
10 changed files with 61 additions and 37 deletions

View File

@@ -121,6 +121,7 @@ class LoginForm extends AbstractLoginFSMExtension implements iLoginDataExtension
);
$oLoginData->AddBlockData('login_input', new LoginBlockData('loginforminput.html.twig', $aData));
$oLoginData->AddBlockData('login_submit', new LoginBlockData('loginformsubmit.html.twig'));
$oLoginData->AddBlockData('login_footer', new LoginBlockData('loginformfooter.html.twig'));
$bEnableResetPassword = empty(MetaModel::GetConfig()->Get('forgot_password')) ? true : MetaModel::GetConfig()->Get('forgot_password');
$sResetPasswordUrl = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?loginop=forgot_pwd';

View File

@@ -157,34 +157,21 @@ class LoginTwigContext
public function Render(NiceWebPage $oPage, $sTwigFile, $aVars = array())
{
$sType = 'html';
$oTemplate = $this->GetTwig()->load($sTwigFile);
$oPage->add($oTemplate->renderBlock('body', $aVars));
$oPage->add_script($oTemplate->renderBlock('script', $aVars));
$oPage->add_ready_script($oTemplate->renderBlock('ready_script', $aVars));
$oPage->add_style($oTemplate->renderBlock('css', $aVars));
if (preg_match('/.*\.(html|ready\.js|js)\.twig/U', $sTwigFile, $matches))
// Render CSS links
foreach ($this->aPluginFormData as $oFormData)
{
$sType = $matches[1];
}
switch ($sType)
{
case 'html':
$oPage->add($this->GetTwig()->render($sTwigFile, $aVars));
// Render CSS links
foreach ($this->aPluginFormData as $oFormData)
{
/** @var \LoginTwigData $oFormData */
$sCSSFile = $oFormData->GetCSSFile();
if (!empty($sCSSFile))
{
$oPage->add_linked_stylesheet($sCSSFile);
}
}
break;
case 'js':
$oPage->add_script($this->GetTwig()->render($sTwigFile, $aVars));
break;
case 'ready.js':
$oPage->add_ready_script($this->GetTwig()->render($sTwigFile, $aVars));
break;
/** @var \LoginTwigData $oFormData */
$sCSSFile = $oFormData->GetCSSFile();
if (!empty($sCSSFile))
{
$oPage->add_linked_stylesheet($sCSSFile);
}
}
}

View File

@@ -175,7 +175,6 @@ class LoginWebPage extends NiceWebPage
$aVars['sFailureReason'] = $sFailureReason;
$oTwigContext->Render($this, 'forgotpwdform.html.twig', $aVars);
$oTwigContext->Render($this, 'forgotpwdform.ready.js.twig');
}
protected function ForgotPwdGo()
@@ -277,7 +276,6 @@ class LoginWebPage extends NiceWebPage
}
$oTwigContext->Render($this, 'resetpwdform.html.twig', $aVars);
$oTwigContext->Render($this, 'resetpwdform.js.twig');
}
public function DoResetPassword()
@@ -326,7 +324,6 @@ class LoginWebPage extends NiceWebPage
$oTwigContext = new LoginTwigContext();
$aVars = $oTwigContext->GetDefaultVars();
$aVars['bFailedLogin'] = $bFailedLogin;
$oTwigContext->Render($this, 'changepwdform.js.twig');
$oTwigContext->Render($this, 'changepwdform.html.twig', $aVars);
}