Просмотр исходного кода

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

fusionate 2 лет назад
Родитель
Сommit
0306094880

+ 3 - 3
core/authentication/resources/classes/authentication.php

@@ -40,7 +40,7 @@ class authentication {
 			}
 
 		//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';
 			}
 
@@ -53,7 +53,7 @@ class authentication {
 			foreach ($_SESSION['authentication']['methods'] as $name) {
 
 				//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;
 				}
 
@@ -468,4 +468,4 @@ $response = $auth->validate();
 print_r($response);
 */
 
-?>
+?>

+ 3 - 1
core/authentication/resources/classes/plugins/email.php

@@ -75,6 +75,7 @@ class plugin_email {
 				$view->assign("login_logo_height", $settings['theme']['login_logo_height']);
 				$view->assign("login_logo_source", $settings['theme']['logo']);
 				$view->assign("button_login", $text['button-login']);
+				$view->assign("button_cancel", $text['button-cancel']);
 
 				//show the views
 				$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_source", $settings['theme']['logo']);
 				$view->assign("button_verify", $text['label-verify']);
+				$view->assign("button_cancel", $text['button-cancel']);
 
 				//debug information
 				//echo "<pre>\n";
@@ -391,4 +393,4 @@ class plugin_email {
 	}
 }
 
-?>
+?>

+ 5 - 2
core/authentication/resources/classes/plugins/totp.php

@@ -81,6 +81,7 @@ class plugin_totp {
 				$view->assign("login_logo_height", $settings['theme']['login_logo_height']);
 				$view->assign("login_logo_source", $settings['theme']['logo']);
 				$view->assign("button_login", $text['button-login']);
+				$view->assign("button_cancel", $text['button-cancel']);
 				$view->assign("favicon", $settings['theme']['favicon']);
 
 				//show the views
@@ -114,7 +115,7 @@ class plugin_totp {
 				$sql .= "	username = :username\n";
 				$sql .= "	or user_email = :username\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)
 					$sql .= "and domain_uuid = :domain_uuid ";
 					$parameters['domain_uuid'] = $this->domain_uuid;
@@ -164,6 +165,7 @@ class plugin_totp {
 				$view->init();
 
 				//assign values to the template
+				$view->assign("project_path", PROJECT_PATH);
 				$view->assign("login_destination_url", $settings['login']['destination']);
 				$view->assign("favicon", $settings['theme']['favicon']);
 				$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_source", $settings['theme']['logo']);
 				$view->assign("favicon", $settings['theme']['favicon']);
+				$view->assign("button_cancel", $text['button-cancel']);
 
 				//show the views
 				if ($_SESSION['authentication']['plugin']['database']['authorized'] && empty($this->user_totp_secret)) {
@@ -362,4 +365,4 @@ class plugin_totp {
 	}
 }
 
-?>
+?>

+ 8 - 5
core/authentication/resources/views/email.htm

@@ -12,18 +12,21 @@
 	<body>
 		<div id='page' align='center'>
 			<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=''>
-					<div>
+					<div class='login_text'>
 						{$login_email_description}
 						<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}" />
-						<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}" />
 					</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>
 				</form>
 			</div>
 		</div>
+		<script>document.getElementsByName('authentication_code')[0].focus();</script>
 	</body>
-</html>
+</html>

+ 2 - 1
core/authentication/resources/views/login.htm

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

+ 6 - 4
core/authentication/resources/views/totp.htm

@@ -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 />
 				<form method='post' name='frm' action=''>
 					<div>
-						<input class='formfld' type='text' style='text-align: center;' name='authentication_code' maxlength='255' placeholder="{$login_authentication_code}" value="{$authentication_code}" />
-						<br /><br />
+						<input class='formfld' type='text' style='text-align: center;' name='authentication_code' maxlength='255' placeholder="{$login_authentication_code}" />
 					</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>
 				</form>
 			</div>
 		</div>
+		<script>document.getElementsByName('authentication_code')[0].focus();</script>
 	</body>
-</html>
+</html>

+ 6 - 6
core/authentication/resources/views/totp_secret.htm

@@ -12,18 +12,18 @@
 	<body>
 		<div id='page' align='center'>
 			<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=''>
-					<div id='totp_qr'>
-						{$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 />
+					<div id='totp_qr' class='login_text'>
 						{$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>
-						<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>
 				</form>
 			</div>
 		</div>
 	</body>
-</html>
+</html>

+ 4 - 1
core/authentication/resources/views/username.htm

@@ -19,9 +19,12 @@
 					</div>
 					<div>
 						<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>
 				</form>
 			</div>
 		</div>
+		<script>document.getElementsByName('username')[0].focus();</script>
 	</body>
-</html>
+</html>

+ 10 - 0
themes/default/css.php

@@ -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_color_hover = $_SESSION['theme']['input_border_color_hover']['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_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;
@@ -1455,6 +1458,13 @@ else { //default: white
 		text-decoration: none;
 		}
 
+	.login_text {
+		color: <?=$login_text_color?> !important;
+		font-size: <?=$login_text_size?>;
+		font-family: <?=$login_text_font?>;
+		text-decoration: none;
+		}
+
 	<?php
 	//determine body padding & margins (overides on main_content style below) based on menu selection
 		switch ($menu_style) {