Authentication: Added some polish, Cancel links, PHP 8.1 updates.

This commit is contained in:
fusionate 2023-06-23 00:14:07 +00:00
parent 7c85bc95f6
commit 6bcc5aff5e
No known key found for this signature in database
9 changed files with 47 additions and 23 deletions

View File

@ -40,7 +40,7 @@ class authentication {
} }
//set the default authentication method to the database //set the default authentication method to the database
if (!is_array($_SESSION['authentication']['methods'])) { if (empty($_SESSION['authentication']['methods']) || !is_array($_SESSION['authentication']['methods'])) {
$_SESSION['authentication']['methods'][] = 'database'; $_SESSION['authentication']['methods'][] = 'database';
} }
@ -53,7 +53,7 @@ class authentication {
foreach ($_SESSION['authentication']['methods'] as $name) { foreach ($_SESSION['authentication']['methods'] as $name) {
//already processed the plugin move to the next plugin //already processed the plugin move to the next plugin
if (!empty($_SESSION['authentication']['plugin']) && $_SESSION['authentication']['plugin'][$name]['authorized']) { if (!empty($_SESSION['authentication']['plugin']) && !empty($_SESSION['authentication']['plugin'][$name]) && $_SESSION['authentication']['plugin'][$name]['authorized']) {
continue; continue;
} }
@ -468,4 +468,4 @@ $response = $auth->validate();
print_r($response); print_r($response);
*/ */
?> ?>

View File

@ -75,6 +75,7 @@ class plugin_email {
$view->assign("login_logo_height", $settings['theme']['login_logo_height']); $view->assign("login_logo_height", $settings['theme']['login_logo_height']);
$view->assign("login_logo_source", $settings['theme']['logo']); $view->assign("login_logo_source", $settings['theme']['logo']);
$view->assign("button_login", $text['button-login']); $view->assign("button_login", $text['button-login']);
$view->assign("button_cancel", $text['button-cancel']);
//show the views //show the views
$content = $view->render('username.htm'); $content = $view->render('username.htm');
@ -255,6 +256,7 @@ class plugin_email {
$view->assign("login_logo_height", $settings['theme']['login_logo_height']); $view->assign("login_logo_height", $settings['theme']['login_logo_height']);
$view->assign("login_logo_source", $settings['theme']['logo']); $view->assign("login_logo_source", $settings['theme']['logo']);
$view->assign("button_verify", $text['label-verify']); $view->assign("button_verify", $text['label-verify']);
$view->assign("button_cancel", $text['button-cancel']);
//debug information //debug information
//echo "<pre>\n"; //echo "<pre>\n";
@ -391,4 +393,4 @@ class plugin_email {
} }
} }
?> ?>

View File

@ -81,6 +81,7 @@ class plugin_totp {
$view->assign("login_logo_height", $settings['theme']['login_logo_height']); $view->assign("login_logo_height", $settings['theme']['login_logo_height']);
$view->assign("login_logo_source", $settings['theme']['logo']); $view->assign("login_logo_source", $settings['theme']['logo']);
$view->assign("button_login", $text['button-login']); $view->assign("button_login", $text['button-login']);
$view->assign("button_cancel", $text['button-cancel']);
$view->assign("favicon", $settings['theme']['favicon']); $view->assign("favicon", $settings['theme']['favicon']);
//show the views //show the views
@ -114,7 +115,7 @@ class plugin_totp {
$sql .= " username = :username\n"; $sql .= " username = :username\n";
$sql .= " or user_email = :username\n"; $sql .= " or user_email = :username\n";
$sql .= ")\n"; $sql .= ")\n";
if ($_SESSION["users"]["unique"]["text"] != "global") { if (empty($_SESSION["users"]["unique"]["text"]) || $_SESSION["users"]["unique"]["text"] != "global") {
//unique username per domain (not globally unique across system - example: email address) //unique username per domain (not globally unique across system - example: email address)
$sql .= "and domain_uuid = :domain_uuid "; $sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $this->domain_uuid; $parameters['domain_uuid'] = $this->domain_uuid;
@ -164,6 +165,7 @@ class plugin_totp {
$view->init(); $view->init();
//assign values to the template //assign values to the template
$view->assign("project_path", PROJECT_PATH);
$view->assign("login_destination_url", $settings['login']['destination']); $view->assign("login_destination_url", $settings['login']['destination']);
$view->assign("favicon", $settings['theme']['favicon']); $view->assign("favicon", $settings['theme']['favicon']);
$view->assign("login_title", $text['label-verify']); $view->assign("login_title", $text['label-verify']);
@ -172,6 +174,7 @@ class plugin_totp {
$view->assign("login_logo_height", $settings['theme']['login_logo_height']); $view->assign("login_logo_height", $settings['theme']['login_logo_height']);
$view->assign("login_logo_source", $settings['theme']['logo']); $view->assign("login_logo_source", $settings['theme']['logo']);
$view->assign("favicon", $settings['theme']['favicon']); $view->assign("favicon", $settings['theme']['favicon']);
$view->assign("button_cancel", $text['button-cancel']);
//show the views //show the views
if ($_SESSION['authentication']['plugin']['database']['authorized'] && empty($this->user_totp_secret)) { if ($_SESSION['authentication']['plugin']['database']['authorized'] && empty($this->user_totp_secret)) {
@ -362,4 +365,4 @@ class plugin_totp {
} }
} }
?> ?>

View File

@ -12,18 +12,21 @@
<body> <body>
<div id='page' align='center'> <div id='page' align='center'>
<div id='default_login'> <div id='default_login'>
<a href='{$project_path}/'><img id='login_logo' style='width: {$login_logo_width}; height: {$login_logo_height};' src='{$login_logo_source}' /></a><br />
<form method='post' name='frm' action=''> <form method='post' name='frm' action=''>
<div> <div class='login_text'>
{$login_email_description} {$login_email_description}
<br /><br /> <br /><br />
<input class='formfld' type='text' style='text-align: center; min-width: 200px; width: 200px; margin-bottom: 8px;' name='authentication_code' maxlength='255' placeholder="{$login_authentication_code}" value="{$authentication_code}" /> <input class='formfld' type='text' style='text-align: center; min-width: 200px; width: 200px; margin-bottom: 8px;' name='authentication_code' maxlength='255' placeholder="{$login_authentication_code}" />
<br /><br />
</div> </div>
<div> <div>
<input type='submit' name='' class='btn' value='{$button_verify}' /> <input type='submit' name='' class='btn' style='width: 100px; margin-top: 15px;' value='{$button_verify}' />
<br /><br />
<a class='login_link' href='{$project_path}/logout.php'>{$button_cancel}</a>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
<script>document.getElementsByName('authentication_code')[0].focus();</script>
</body> </body>
</html> </html>

View File

@ -74,5 +74,6 @@
</form> </form>
</div> </div>
</div> </div>
<script>document.getElementsByName('username')[0].focus();</script>
</body> </body>
</html> </html>

View File

@ -15,14 +15,16 @@
<a href='{$project_path}/'><img id='login_logo' style='width: {$login_logo_width}; height: {$login_logo_height};' src='{$login_logo_source}' /></a><br /> <a href='{$project_path}/'><img id='login_logo' style='width: {$login_logo_width}; height: {$login_logo_height};' src='{$login_logo_source}' /></a><br />
<form method='post' name='frm' action=''> <form method='post' name='frm' action=''>
<div> <div>
<input class='formfld' type='text' style='text-align: center;' name='authentication_code' maxlength='255' placeholder="{$login_authentication_code}" value="{$authentication_code}" /> <input class='formfld' type='text' style='text-align: center;' name='authentication_code' maxlength='255' placeholder="{$login_authentication_code}" />
<br /><br />
</div> </div>
<div> <div>
<input type='submit' name='' class='btn' value='{$button_verify}' /> <input type='submit' name='' class='btn' style='width: 100px; margin-top: 15px;' value='{$button_verify}' />
<br /><br />
<a class='login_link' href='{$project_path}/logout.php'>{$button_cancel}</a>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
<script>document.getElementsByName('authentication_code')[0].focus();</script>
</body> </body>
</html> </html>

View File

@ -12,18 +12,18 @@
<body> <body>
<div id='page' align='center'> <div id='page' align='center'>
<div id='default_login' style='max-width: 400px;'> <div id='default_login' style='max-width: 400px;'>
<a href='{$project_path}/'><img id='login_logo' style='width: {$login_logo_width}; height: {$login_logo_height};' src='{$login_logo_source}'/></a><br /> <a href='{$project_path}/'><img id='login_logo' style='width: {$login_logo_width}; height: {$login_logo_height};' src='{$login_logo_source}' /></a><br />
<form method='post' name='frm' action=''> <form method='post' name='frm' action=''>
<div id='totp_qr'> <div id='totp_qr' class='login_text'>
{$totp_secret}<br /><br />
<img src="data:image/jpeg;base64,{$totp_image}" style='margin-top: 0px; padding: 5px; background: white; max-width: 100%;' /><br /><br />
{$totp_description}<br /><br /> {$totp_description}<br /><br />
<img src="data:image/jpeg;base64,{$totp_image}" style='margin-top: 0px; padding: 5px; background: white; max-width: 100%;' /><br /><br />
{$totp_secret}<br />
</div> </div>
<div> <div>
<input type='submit' name='' class='btn' value='{$button_next}' /> <input type='submit' name='' class='btn' style='width: 100px; margin-top: 15px;' value='{$button_next}' />
</div> </div>
</form> </form>
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -19,9 +19,12 @@
</div> </div>
<div> <div>
<input type='submit' id='btn_login' class='btn' style='width: 100px; margin-top: 15px;' value='{$button_login}' /> <input type='submit' id='btn_login' class='btn' style='width: 100px; margin-top: 15px;' value='{$button_login}' />
<br /><br />
<a class='login_link' href='{$project_path}/logout.php'>{$button_cancel}</a>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
<script>document.getElementsByName('username')[0].focus();</script>
</body> </body>
</html> </html>

View File

@ -136,6 +136,9 @@ $input_shadow_outer_color_focus = isset($_SESSION['theme']['input_shadow_outer_c
$input_border_radius = $_SESSION['theme']['input_border_radius']['text'] ?? null; $input_border_radius = $_SESSION['theme']['input_border_radius']['text'] ?? null;
$input_border_color_hover = $_SESSION['theme']['input_border_color_hover']['text'] ?? '#c0c0c0'; $input_border_color_hover = $_SESSION['theme']['input_border_color_hover']['text'] ?? '#c0c0c0';
$input_border_color_focus = $_SESSION['theme']['input_border_color_focus']['text'] ?? '#c0c0c0'; $input_border_color_focus = $_SESSION['theme']['input_border_color_focus']['text'] ?? '#c0c0c0';
$login_text_color = $_SESSION['theme']['login_text_color']['text'] ?? '#888888';
$login_text_size = $_SESSION['theme']['login_text_size']['text'] ?? '12px';
$login_text_font = $_SESSION['theme']['login_text_font']['text'] ?? 'Arial';
$login_input_text_font = $_SESSION['theme']['login_input_text_font']['text'] ?? $input_text_font; $login_input_text_font = $_SESSION['theme']['login_input_text_font']['text'] ?? $input_text_font;
$login_input_text_size = $_SESSION['theme']['login_input_text_size']['text'] ?? $input_text_size; $login_input_text_size = $_SESSION['theme']['login_input_text_size']['text'] ?? $input_text_size;
$login_input_text_color = $_SESSION['theme']['login_input_text_color']['text'] ?? $input_text_color; $login_input_text_color = $_SESSION['theme']['login_input_text_color']['text'] ?? $input_text_color;
@ -1455,6 +1458,13 @@ else { //default: white
text-decoration: none; text-decoration: none;
} }
.login_text {
color: <?=$login_text_color?> !important;
font-size: <?=$login_text_size?>;
font-family: <?=$login_text_font?>;
text-decoration: none;
}
<?php <?php
//determine body padding & margins (overides on main_content style below) based on menu selection //determine body padding & margins (overides on main_content style below) based on menu selection
switch ($menu_style) { switch ($menu_style) {