Преглед изворни кода

U theme login/logout; + test auth class

Piotr Labudda пре 4 година
родитељ
комит
17a0646239
6 измењених фајлова са 111 додато и 19 уклоњено
  1. 24 2
      auth.php
  2. 0 3
      config.php
  3. BIN
      theme/assets/logo-biall-net.png
  4. 14 14
      theme/panel_biall_net.php
  5. 49 0
      theme/view/login.php
  6. 24 0
      theme/view/logout.php

+ 24 - 2
auth.php

@@ -20,9 +20,31 @@
  * - EMAIL_IMAP_IMPORT_USERNAME // EMAIL_IMAP_IMPORT_USERNAME
  */
 
-class Theme_Auth_Panel_biall_net { // TODO: implements AuthBaseInterface {
+class Theme_Auth_panel_biall_net { // TODO: implements AuthBaseInterface {
+
+	static function login($login, $pass) { // @return User object or null
+
+		if (empty($login) || empty($pass)) throw new Exception("Proszę podać poprawny login i hasło!");
+
+		{ // TODO: TEST
+			$login = "krzys.dworski@gmail.com"; // COMPANIES.user_mail_contact
+			$pass = "76022801989"; // TODO: COMPANIES.P_PESEL or COMPANIES.PASSWD varchar(100) ?
+		}
+
+		$item = DB::getPDO()->fetchFirst("
+			select c.ID, c.user_mail_contact, c.P_PESEL, c.PASSWD
+			from COMPANIES c
+			where c.user_mail_contact like :email
+		", [
+			':email' => $login,
+		]);
+		// [ID] => 12807
+		// [user_mail_contact] => krzys.dworski@gmail.com
+		// [P_PESEL] => 76022801989
+		// [PASSWD] => 76022801989
+
+		throw new Exception("TODO: Proszę podać poprawny login i hasło!");
 
-	static function auth($login, $pass) { // @return User object or null
 		return null;
 
 		return (object)[

+ 0 - 3
config-example.php → config.php

@@ -1,8 +1,5 @@
 <?php
 
-// rename file to: `config.php`
-// @use: Config::get('VIEW_TABLE_HIDE_PROCESS_LIST')
-
 return [
     'VIEW_TABLE_HIDE_PROCESS_LIST' => true,
     'LEGACY_INIT_FUNCTIONS_OFF' => true,

BIN
theme/assets/logo-biall-net.png


+ 14 - 14
theme/base.php → theme/panel_biall_net.php

@@ -2,7 +2,7 @@
 
 // TODO: file and class name must have the same name as project
 
-class Theme_base extends ThemeDefault {
+class Theme_panel_biall_net extends ThemeDefault {
 
 	// function head() { // TODO: echo 'html tag inside <head>'
 	// }
@@ -15,19 +15,19 @@ class Theme_base extends ThemeDefault {
 	// 	include dirname(__FILE__) . '/view/footer.php';
 	// }
 
-	// function login($data) { // TODO: login view
-	// 	if (is_array($data) && !empty($data)) {
-	// 		extract($data);
-	// 	}
-	// 	include dirname(__FILE__) . '/view/login.php';
-	// }
-
-	// function logout($data) { // TODO: logout view
-	// 	if (is_array($data) && !empty($data)) {
-	// 		extract($data);
-	// 	}
-	// 	include dirname(__FILE__) . '/view/logout.php';
-	// }
+	function login($data) { // TODO: login view
+		if (is_array($data) && !empty($data)) {
+			extract($data);
+		}
+		include dirname(__FILE__) . '/view/login.php';
+	}
+
+	function logout($data) { // TODO: logout view
+		if (is_array($data) && !empty($data)) {
+			extract($data);
+		}
+		include dirname(__FILE__) . '/view/logout.php';
+	}
 
 	// function home($data) { // TODO: home page view
 	// 	if (is_array($data) && !empty($data)) {

+ 49 - 0
theme/view/login.php

@@ -0,0 +1,49 @@
+<div class="container">
+
+	<?php // UI::loadTemplate('apple-menu'); ?>
+
+	<div style="text-align:center; padding:36px">
+		<img src="<?= $this->asset("assets/logo-biall-net.png"); ?>">
+	</div>
+
+	<form name="LOGIN" action="" method="post" class="form-horizontal" style="width:574px; margin:0 auto;">
+		<fieldset>
+			<div class="form-group">
+				<label class="col-sm-3 control-label" for="ADM_ACCOUNT">Użytkownik:</label>
+				<div class="col-sm-6">
+					<input type="text" name="ADM_ACCOUNT" value="" id="username" class="form-control">
+				</div>
+			</div>
+			<div class="form-group">
+				<label class="col-sm-3 control-label" for="ADM_PASSWD">Hasło:</label>
+				<div class="col-sm-6">
+					<input type="password" name="ADM_PASSWD" class="form-control"><br>
+				</div>
+			</div>
+			<?php if (!empty($errors)) : ?>
+				<div class="form-group">
+					<div class="col-sm-9">
+						<div class="alert alert-danger"><?php echo implode('<br>', $errors); ?></div>
+					</div>
+				</div>
+			<?php endif; ?>
+			<div class="form-group">
+				<div class="col-sm-9 col-sm-offset-3">
+					<!--
+					<label class="checkbox">
+						<input name="NOPREINIT" type="checkbox"> Szybkie logowanie bez inicjalizacji kolumn
+					</label>
+					-->
+					<input name="LOGIN" type="SUBMIT" value="LOGIN" class="btn btn-primary">
+				</div>
+			</div>
+		</fieldset>
+	</form>
+
+	<script>
+		jQuery(document).ready(function(){
+			document.getElementById('username').focus();
+		});
+	</script>
+
+</div>

+ 24 - 0
theme/view/logout.php

@@ -0,0 +1,24 @@
+<div class="container">
+
+	<?php // UI::loadTemplate('apple-menu'); ?>
+
+	<div style="text-align:center; padding:36px">
+		<img src="<?= $this->asset("assets/logo-biall-net.png"); ?>">
+	</div>
+
+	<div class="container" style="max-width:574px">
+		<?php if (!empty($errors)) : ?>
+			<?php foreach ($errors as $errMsg) : ?>
+				<div class="alert alert-danger" style="text-align:center"><?= $errMsg; ?></div>
+			<?php endforeach; ?>
+		<?php else : ?>
+			<div class="alert alert-info" style="text-align:center">
+				Zostałeś wylogowany
+			</div>
+		<?php endif; ?>
+		<div style="padding:24px auto; text-align:center">
+			<a  class="btn btn-primary" href="index.php"> zaloguj się </a>
+		</div>
+	</div>
+
+</div>