add parameters to cookies and now work
This commit is contained in:
parent
3b94dcec9b
commit
2ddaa38d6a
@ -26,7 +26,7 @@ class UserManager
|
|||||||
if ($user = Db::loadOne ('SELECT * FROM users WHERE LOWER(username)=LOWER(?)', array ($username))) {
|
if ($user = Db::loadOne ('SELECT * FROM users WHERE LOWER(username)=LOWER(?)', array ($username))) {
|
||||||
if ($user['password'] == UserManager::getHashPassword($password)) {
|
if ($user['password'] == UserManager::getHashPassword($password)) {
|
||||||
if (isset($rememberMe) && $rememberMe == 'true') {
|
if (isset($rememberMe) && $rememberMe == 'true') {
|
||||||
setcookie ("rememberMe" . str_replace(".", "_", $_SERVER['HTTP_HOST']), $this->setEncryptedCookie($user['username']), time () + (30 * 24 * 60 * 60 * 1000), "/", $_SERVER['HTTP_HOST'], 1);
|
setcookie ("rememberMe", $this->setEncryptedCookie($user['username']), time () + (30 * 24 * 60 * 60 * 1000), str_replace("login", "", str_replace('https://' . $_SERVER['HTTP_HOST'], "", $_SERVER['HTTP_REFERER'])), $_SERVER['HTTP_HOST'], 1);
|
||||||
}
|
}
|
||||||
$_SESSION['user']['id'] = $user['user_id'];
|
$_SESSION['user']['id'] = $user['user_id'];
|
||||||
$page = "./index.php";
|
$page = "./index.php";
|
||||||
@ -51,8 +51,8 @@ class UserManager
|
|||||||
if (isset ($_SESSION['user']) && isset($_SESSION['user']['id'])) {
|
if (isset ($_SESSION['user']) && isset($_SESSION['user']['id'])) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (isset ($_COOKIE['rememberMe' . str_replace(".", "_", $_SERVER['HTTP_HOST'])])){
|
if (isset ($_COOKIE['rememberMe'])){
|
||||||
if ($user = Db::loadOne ('SELECT * FROM users WHERE LOWER(username)=LOWER(?)', array ($this->getDecryptedCookie($_COOKIE['rememberMe' . str_replace(".", "_", $_SERVER['HTTP_HOST'])])))) {
|
if ($user = Db::loadOne ('SELECT * FROM users WHERE LOWER(username)=LOWER(?)', array ($this->getDecryptedCookie($_COOKIE['rememberMe'])))) {
|
||||||
$_SESSION['user']['id'] = $user['user_id'];
|
$_SESSION['user']['id'] = $user['user_id'];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ class UserManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function logout () {
|
public function logout () {
|
||||||
setcookie ("rememberMe" . str_replace(".", "_", $_SERVER['HTTP_HOST']),"", time() - (30 * 24 * 60 * 60 * 1000), "/", $_SERVER['HTTP_HOST'], 1);
|
setcookie ("rememberMe","", time() - (30 * 24 * 60 * 60 * 1000), str_replace("login", "", str_replace('https://' . $_SERVER['HTTP_HOST'], "", $_SERVER['HTTP_REFERER'])), $_SERVER['HTTP_HOST'], 1);
|
||||||
unset($_SESSION['user']);
|
unset($_SESSION['user']);
|
||||||
session_destroy();
|
session_destroy();
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ if (isset($_POST) && !empty($_POST)){
|
|||||||
DashboardManager::Add($subDeviceId);
|
DashboardManager::Add($subDeviceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: /vasek/home/' . strtolower(basename(__FILE__, '.php')), TRUE);
|
header('Location: /vasek/home/' . strtolower(basename(__FILE__, '.php')), TRUE);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
$partial = new Partial('head');
|
$partial = new Partial('head');
|
||||||
$partial->render();
|
$partial->render();
|
||||||
?>
|
?>
|
||||||
<title><?php echo $TITLE ?></title>
|
<title><?php echo $TITLE; ?></title>
|
||||||
</head>
|
</head>
|
||||||
<body class="no-transitions">
|
<body class="no-transitions">
|
||||||
<div class="row no-gutters main">
|
<div class="row no-gutters main">
|
||||||
|
@ -4,7 +4,10 @@
|
|||||||
include_once './config.php';
|
include_once './config.php';
|
||||||
|
|
||||||
//setup
|
//setup
|
||||||
ini_set ('session.cookie_httponly', 1);
|
ini_set ('session.cookie_httponly', '1');
|
||||||
|
ini_set('session.cookie_domain', $_SERVER['HTTP_HOST']);
|
||||||
|
ini_set('session.cookie_path', str_replace("login", "", str_replace('https://' . $_SERVER['HTTP_HOST'], "", $_SERVER['HTTP_REFERER'])));
|
||||||
|
ini_set('session.cookie_secure', '1');
|
||||||
session_start ();
|
session_start ();
|
||||||
mb_internal_encoding ("UTF-8");
|
mb_internal_encoding ("UTF-8");
|
||||||
|
|
||||||
@ -42,7 +45,7 @@ Db::connect (DBHOST, DBUSER, DBPASS, DBNAME);
|
|||||||
//TODO: Přesunout do Login Pohledu
|
//TODO: Přesunout do Login Pohledu
|
||||||
$userManager = new UserManager();
|
$userManager = new UserManager();
|
||||||
if (isset($_POST['username']) && isset($_POST['password']) ) {
|
if (isset($_POST['username']) && isset($_POST['password']) ) {
|
||||||
$userManager->login($_POST['username'], $_POST['password'], $_POST['remember']);
|
$userManager->login($_POST['username'], $_POST['password'], (isset ($_POST['remember']) ? $_POST['remember'] : 'false'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$logManager = new LogManager();
|
$logManager = new LogManager();
|
||||||
|
Loading…
Reference in New Issue
Block a user