Improve login and recover password templates

This commit is contained in:
Benjamin Renard 2020-05-07 11:36:25 +02:00
parent b9477a8503
commit cd8908391d
3 changed files with 36 additions and 77 deletions

View file

@ -603,8 +603,8 @@ class LSsession {
if (isset($_GET['LSsession_recoverPassword'])) {
$recoveryPasswordInfos = self :: recoverPasswd (
$_REQUEST['LSsession_user'],
$_GET['recoveryHash']
(isset($_REQUEST['LSsession_user'])?$_REQUEST['LSsession_user']:''),
(isset($_GET['recoveryHash'])?$_GET['recoveryHash']:'')
);
}
else {
@ -778,18 +778,10 @@ class LSsession {
}
if ($step==1) {
if ($_SERVER['HTTPS']=='on') {
$recovery_url='https://';
}
else {
$recovery_url='http://';
}
$recovery_url .= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&recoveryHash='.$info;
$subject = self :: $ldapServer['recoverPassword']['recoveryHashMail']['subject'];
$msg = getFData(
self :: $ldapServer['recoverPassword']['recoveryHashMail']['msg'],
$recovery_url
LSurl :: get_public_absolute_url('index')."?LSsession_recoverPassword&recoveryHash=$info"
);
}
else {
@ -1201,31 +1193,11 @@ class LSsession {
*/
public static function displayLoginForm() {
LStemplate :: assign('pagetitle', _('Connection'));
if (isset($_GET['LSsession_logout'])) {
LStemplate :: assign('loginform_action', '');
}
else {
LStemplate :: assign('loginform_action',$_SERVER['REQUEST_URI']);
}
if (count(LSconfig :: get('ldap_servers'))==1) {
LStemplate :: assign('loginform_ldapserver_style','style="display: none"');
}
LStemplate :: assign('loginform_label_ldapserver',_('LDAP server'));
$ldapservers_name=array();
$ldapservers_index=array();
foreach(LSconfig :: get('ldap_servers') as $id => $infos) {
$ldapservers_index[]=$id;
$ldapservers_name[]=__($infos['name']);
}
LStemplate :: assign('loginform_ldapservers_name',$ldapservers_name);
LStemplate :: assign('loginform_ldapservers_index',$ldapservers_index);
LStemplate :: assign('loginform_label_level',_('Level'));
LStemplate :: assign('loginform_label_user',_('Identifier'));
LStemplate :: assign('loginform_label_pwd',_('Password'));
LStemplate :: assign('loginform_label_submit',_('Connect'));
LStemplate :: assign('loginform_label_recoverPassword',_('Forgot your password ?'));
$ldapservers = array();
foreach(LSconfig :: get('ldap_servers') as $id => $infos)
$ldapservers[$id] = __($infos['name']);
LStemplate :: assign('ldapservers', $ldapservers);
LStemplate :: assign('ldapServerId', (self :: $ldapServerId?self :: $ldapServerId:0));
self :: setTemplate('login.tpl');
self :: addJSscript('LSsession_login.js');
}
@ -1243,25 +1215,12 @@ class LSsession {
*/
public static function displayRecoverPasswordForm($recoveryPasswordInfos) {
LStemplate :: assign('pagetitle', _('Recovery of your credentials'));
LStemplate :: assign('recoverpasswordform_action','?LSsession_recoverPassword');
if (count(LSconfig :: get('ldap_servers'))==1) {
LStemplate :: assign('recoverpasswordform_ldapserver_style','style="display: none"');
}
LStemplate :: assign('recoverpasswordform_label_ldapserver',_('LDAP server'));
$ldapservers_name=array();
$ldapservers_index=array();
foreach(LSconfig :: get('ldap_servers') as $id => $infos) {
$ldapservers_index[]=$id;
$ldapservers_name[]=$infos['name'];
}
LStemplate :: assign('recoverpasswordform_ldapservers_name',$ldapservers_name);
LStemplate :: assign('recoverpasswordform_ldapservers_index',$ldapservers_index);
LStemplate :: assign('recoverpasswordform_label_user',_('Identifier'));
LStemplate :: assign('recoverpasswordform_label_submit',_('Validate'));
LStemplate :: assign('recoverpasswordform_label_back',_('Back'));
$ldapservers = array();
foreach(LSconfig :: get('ldap_servers') as $id => $infos)
$ldapservers[$id] = __($infos['name']);
LStemplate :: assign('ldapservers', $ldapservers);
LStemplate :: assign('ldapServerId', (self :: $ldapServerId?self :: $ldapServerId:0));
$recoverpassword_step = 'start';
$recoverpassword_msg = _('Please fill the identifier field to proceed recovery procedure');

View file

@ -16,17 +16,17 @@
<div class='loginform'>
<img src='{img name='logo'}' alt='Logo' id='loginform_logo' />
<div id='loading_zone'></div>
<form action='{$loginform_action}' method='post'>
<form action='{if $request->current_url}{$request->current_url}{else}index{/if}' method='post'>
<dl class='loginform'>
<dt {$loginform_ldapserver_style}>{$loginform_label_ldapserver|escape:"htmlall"}</dt>
<dd {$loginform_ldapserver_style}>
<select name='LSsession_ldapserver' id='LSsession_ldapserver'>{html_options values=$loginform_ldapservers_index output=$loginform_ldapservers_name selected=$ldapServerId}</select>
<dt {if count($ldapservers) <= 1}style="display: none"{/if}>{tr msg="LDAP server"}</dt>
<dd {if count($ldapservers) <= 1}style="display: none"{/if}>
<select name='LSsession_ldapserver' id='LSsession_ldapserver'>{html_options options=$ldapservers selected=$ldapServerId}</select>
</dd>
<dt class='loginform-level' id='LSsession_topDn_label' {$loginform_ldapserver_style}>{$loginform_label_level|escape:"htmlall"}</dt>
<dd class='loginform-level' {$loginform_ldapserver_style}><select name='LSsession_topDn' id='LSsession_topDn'>{html_options values=$loginform_topdn_index output=$loginform_topdn_name selected=$topDn}</select></dd>
<dt>{$loginform_label_user|escape:"htmlall"}</dt>
<dt class='loginform-level' id='LSsession_topDn_label' {if count($ldapservers) <= 1}style="display: none"{/if}>{tr msg="Level"}</dt>
<dd class='loginform-level' {if count($ldapservers) <= 1}style="display: none"{/if}><select name='LSsession_topDn' id='LSsession_topDn'></select></dd>
<dt>{tr msg="Identifier"}</dt>
<dd><input type='text' name='LSauth_user' /></dd>
<dt>{$loginform_label_pwd|escape:"htmlall"}</dt>
<dt>{tr msg="Password"}</dt>
<dd><input type='password' name='LSauth_pwd' /></dd>
<dt class='LSlang_hidden'>{tr msg="Language"}</dt>
<dd class='LSlang_hidden'>
@ -36,11 +36,11 @@
{/foreach}
</select>
</dd>
<dd><input type='submit' value='{$loginform_label_submit|escape:"htmlall"}' /></dd>
<dd><input type='submit' value='{tr msg="Connect"|escape:"quotes"}' /></dd>
</dl>
</form>
<span>{tr msg="Language"} : <img id='LSlang' src='{img name=$LSlang}' alt='{$LSlang|escape:"htmlall"}' title='{$LSlang|escape:"htmlall"}'/></span>
<a href='?LSsession_recoverPassword' class='LSsession_recoverPassword LSsession_recoverPassword_hidden'>{$loginform_label_recoverPassword|escape:"htmlall"}</a>
<a href='?LSsession_recoverPassword' class='LSsession_recoverPassword LSsession_recoverPassword_hidden'>{tr msg="Forgot your password ?"}</a>
</div>
{include file='ls:LSsession_js.tpl'}
</body>

View file

@ -16,22 +16,22 @@
<img src='{img name='logo'}' alt='Logo' id='recoverpasswordform_logo' />
<div id='loading_zone'></div>
{if $recoverpassword_step == 'start'}
<form action='{$recoverpasswordform_action}' method='post'>
<form action='index?LSsession_recoverPassword' method='post'>
<dl class='recoverpasswordform'>
<dt {$recoverpasswordform_ldapserver_style}>{$recoverpasswordform_label_ldapserver|escape:"htmlall"}</dt>
<dd {$recoverpasswordform_ldapserver_style}>
<select name='LSsession_ldapserver' id='LSsession_ldapserver'>{html_options values=$recoverpasswordform_ldapservers_index output=$recoverpasswordform_ldapservers_name selected=$ldapServerId}</select>
<dt {if count($ldapservers) <= 1}style="display: none"{/if}>{tr msg="LDAP server"}</dt>
<dd {if count($ldapservers) <= 1}style="display: none"{/if}>
<select name='LSsession_ldapserver' id='LSsession_ldapserver'>{html_options options=$ldapservers selected=$ldapServerId}</select>
</dd>
<dt>{$recoverpasswordform_label_user|escape:"htmlall"}</dt>
<dt>{tr msg="Identifier"}</dt>
<dd><input type='text' name='LSsession_user' /></dd>
<dd><input type='submit' value='{$recoverpasswordform_label_submit|escape:"htmlall"}' /></dd>
<dd><input type='submit' value='{tr msg="Validate"|escape:"quotes"}' /></dd>
</dl>
</form>
{/if}
<p id='recoverpassword_msg'>{$recoverpassword_msg|escape:"htmlall"}</p>
<span>{tr msg="Language"} : <img id='LSlang' src='{img name=$LSlang}' alt='{$LSlang|escape:"htmlall"}' title='{$LSlang|escape:"htmlall"}'/></span>
<a href='' id='recoverpassword_back'>{$recoverpasswordform_label_back|escape:"htmlall"}</a>
<a href='' id='recoverpassword_back'>{tr msg="Back"}</a>
</div>
{include file='ls:LSsession_js.tpl'}
</body>