Provide a facility for setting an override URL which will replace the Change Password UI, and the Forgotten Password UI with a clickable link.

This commit is contained in:
Paul Waite 2022-02-09 14:04:07 +13:00 committed by Andrew Ruthven
parent 45035ad488
commit dd5bd9c282
3 changed files with 86 additions and 5 deletions

View File

@ -124,6 +124,24 @@ $c->admin_email ='calendar-admin@example.com';
*/
// $c->list_everyone = false;
/**
* Provide a way of over-riding the default password change UI to render a
* clickable link instead. Usually the UI provides a pair of text boxes to enter
* a new password and confirm password. In some cases where remote authentication
* is being used, the password change process is managed in a more complex way
* and allowing it to be changed locally is not helpful. In this case the UI
* is disabled and an HREF displayed to take the user to the appropriate place for
* facilitating that.
* As well as the Administration UI, this will also affect the Forgotten Password
* UI since it would create a temporary local password. The login HTML rendered by
* libawl-php is over-ridden and replaced by the same HREF as above.
* Users with Administrator privileges will still see the default password change UI.
* Default: unset
*/
// $c->password_change_override = array(
// 'href' => 'https://my.password/changer',
// 'label' => 'My Password Changer'
// );
/***************************************************************************
* *

View File

@ -130,6 +130,59 @@ class DAViCalSession extends Session
}
/**
* Renders some HTML for a basic login panel
*
* @return string The HTML to display a login panel.
*/
function RenderLoginPanel() {
global $c;
$action_target = htmlspecialchars(preg_replace('/\?logout.*$/','',$_SERVER['REQUEST_URI']));
dbg_error_log( "Login", " RenderLoginPanel: action_target='%s'", $action_target );
$userprompt = translate("User Name");
$pwprompt = translate("Password");
$gobutton = htmlspecialchars(translate("GO!"));
$gotitle = htmlspecialchars(translate("Enter your username and password then click here to log in."));
$temppwprompt = translate("If you have forgotten your password then");
$temppwbutton = htmlspecialchars(translate("Help! I've forgotten my password!"));
if (isset($c->password_change_override) ) {
$temppw_html = '<a href="' . $c->password_change_override['href'] . '">' . $c->password_change_override['label'] . '</a>';
} else {
$temppwtitle = htmlspecialchars(translate("Enter a username, if you know it, and click here, to be e-mailed a temporary password."));
$temppw_html = '<input type="submit" value="' . $temppwbutton . '" title="' . $temppwtitle . '" name="lostpass" class="submit" />';
}
$html = <<<EOTEXT
<div id="logon">
<form action="$action_target" method="post">
<table>
<tr>
<th class="prompt">$userprompt:</th>
<td class="entry">
<input class="text" type="text" name="username" size="12" /></td>
</tr>
<tr>
<th class="prompt">$pwprompt:</th>
<td class="entry">
<input class="password" type="password" name="password" size="12" />
</td>
</tr>
<tr>
<th class="prompt">&nbsp;</th>
<td class="entry">
<input type="submit" value="$gobutton" title="$gotitle" name="submit" class="submit" />
</td>
</tr>
</table>
<p>
$temppwprompt: $temppw_html
</p>
</form>
</div>
EOTEXT;
return $html;
}
/**
* Checks that this user is logged in, and presents a login screen if they aren't.

View File

@ -327,12 +327,23 @@ function principal_editor() {
}
$admin_row_entry = '';
$default_passwd_row_entry = '<tr> <th class="right">' . $prompt_password_1 . ':</th> <td class="left">##newpass1.password.$pwstars##</td> </tr>';
$default_passwd_row_entry .= '<tr> <th class="right">' . $prompt_password_2 . ':</th> <td class="left">##newpass2.password.$pwstars##</td> </tr>';
$delete_principal_button = '';
if ( $session->AllowedTo('Admin') ) {
$admin_row_entry = ' <tr> <th class="right">'.$prompt_admin.':</th><td class="left">##is_admin.checkbox##</td> </tr>';
$admin_row_entry .= ' <tr> <th class="right">'.$prompt_active.':</th><td class="left">##user_active.checkbox##</td> </tr>';
$passwd_row_entry = $default_passwd_row_entry;
$admin_row_entry = '<tr> <th class="right">' . $prompt_admin . ':</th><td class="left">##is_admin.checkbox##</td> </tr>';
$admin_row_entry .= '<tr> <th class="right">' . $prompt_active . ':</th><td class="left">##user_active.checkbox##</td> </tr>';
if ( isset($id) )
$delete_principal_button = '<a href="'.$c->base_url . '/admin.php?action=edit&t=principal&subaction=delete_principal&id='.$id.'" class="submit">' . translate("Delete Principal") . '</a>';
$delete_principal_button = '<a href="' . $c->base_url . '/admin.php?action=edit&t=principal&subaction=delete_principal&id='.$id.'" class="submit">' . translate("Delete Principal") . '</a>';
} else {
if ( isset($c->password_change_override) ) {
$passwd_row_entry = '<tr> <th class="right">' . $prompt_password_1 . ':</th>';
$passwd_row_entry .= '<td class="left"><a href="' . $c->password_change_override['href'] . '">';
$passwd_row_entry .= $c->password_change_override['label'] . '</a></td> </tr>';
} else {
$passwd_row_entry = $default_passwd_row_entry;
}
}
$email_unique = '';
@ -401,8 +412,7 @@ label.privilege {
</tr></table>
</td></tr>
<tr> <th class="right">$prompt_username:</th> <td class="left">##xxxxusername.input.50##</td> </tr>
<tr> <th class="right">$prompt_password_1:</th> <td class="left">##newpass1.password.$pwstars##</td> </tr>
<tr> <th class="right">$prompt_password_2:</th> <td class="left">##newpass2.password.$pwstars##</td> </tr>
$passwd_row_entry
<tr> <th class="right">$prompt_fullname:</th> <td class="left">##fullname.input.50##</td> </tr>
<tr> <th class="right">$prompt_email:</th> <td class="left">##email.input.50##$email_unique</td> </tr>
<tr> <th class="right">$prompt_locale:</th> <td class="left">##locale.select##</td> </tr>