Merge branch 'remastering' of https://gitea.steelants.cz/SH/PHP_SMART_HOME_V3 into remastering
This commit is contained in:
commit
4b94ef29c1
@ -44,7 +44,6 @@ class UserManager
|
|||||||
public static function login ($username, $password, $rememberMe) {
|
public static function login ($username, $password, $rememberMe) {
|
||||||
try {
|
try {
|
||||||
if ($user = Db::loadOne ('SELECT * FROM users WHERE (LOWER(username)=LOWER(?) OR LOWER(email)=LOWER(?))', array ($username, $username))) {
|
if ($user = Db::loadOne ('SELECT * FROM users WHERE (LOWER(username)=LOWER(?) OR LOWER(email)=LOWER(?))', array ($username, $username))) {
|
||||||
var_dump($user);
|
|
||||||
if ($user['password'] == UserManager::getHashPassword($password)) {
|
if ($user['password'] == UserManager::getHashPassword($password)) {
|
||||||
if (isset($rememberMe) && $rememberMe == 'true') {
|
if (isset($rememberMe) && $rememberMe == 'true') {
|
||||||
setcookie ("rememberMe", self::setEncryptedCookie($user['username']), time () + (30 * 24 * 60 * 60 * 1000), BASEDIR, $_SERVER['HTTP_HOST'], 1);
|
setcookie ("rememberMe", self::setEncryptedCookie($user['username']), time () + (30 * 24 * 60 * 60 * 1000), BASEDIR, $_SERVER['HTTP_HOST'], 1);
|
||||||
@ -59,7 +58,9 @@ class UserManager
|
|||||||
throw new PDOException("Uživatel s tím to jménem neexistuje!");
|
throw new PDOException("Uživatel s tím to jménem neexistuje!");
|
||||||
}
|
}
|
||||||
} catch(PDOException $error) {
|
} catch(PDOException $error) {
|
||||||
echo $error->getMessage();
|
$_SESSION['msg'] = $error->getMessage();
|
||||||
|
unset($_POST);
|
||||||
|
header('Location: ' . BASEURL . 'login');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,10 @@
|
|||||||
<div class="label">Remember me:</div>
|
<div class="label">Remember me:</div>
|
||||||
<input class="" type="checkbox" name="remember" value="true"/>
|
<input class="" type="checkbox" name="remember" value="true"/>
|
||||||
</div>
|
</div>
|
||||||
|
<?php if (!empty ($_SESSION['msg'])): ?>
|
||||||
|
<label class="message"><?php echo $_SESSION['msg']; ?></label><br/><br/>
|
||||||
|
<?php unset ($_SESSION['msg']); ?>
|
||||||
|
<?php endif; ?>
|
||||||
<input type="submit" class="button" name="login" value="Login"/>
|
<input type="submit" class="button" name="login" value="Login"/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -475,6 +475,15 @@ html {
|
|||||||
color: #a32929;
|
color: #a32929;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message {
|
||||||
|
border: 2px solid #a32929;
|
||||||
|
background-color: #f6cbcb;
|
||||||
|
color: #a32929;
|
||||||
|
padding: .75rem 1rem;
|
||||||
|
margin-bottom: .8em;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
|
Loading…
Reference in New Issue
Block a user