Better Login

This commit is contained in:
JonatanRek
2019-10-13 12:29:07 +02:00
parent 8274e51eb6
commit d9ca8fcb1a
3 changed files with 51 additions and 2 deletions

View File

@@ -62,9 +62,14 @@ class UserManager
}
public function logout () {
setcookie ("rememberMe","", time() - (30 * 24 * 60 * 60 * 1000), str_replace("login", "", str_replace('https://' . $_SERVER['HTTP_HOST'], "", $_SERVER['REQUEST_URI'])), $_SERVER['HTTP_HOST'], 1);
unset($_SESSION['user']);
session_destroy();
if (isset($_COOKIE['rememberMe'])){
//unset($_COOKIE['rememberMe']);
setcookie ("rememberMe2", $this->setEncryptedCookie($user['username']), time () + (30 * 24 * 60 * 60 * 1000), '/vasek/home/', $_SERVER['HTTP_HOST'], 1);
setcookie("token", "restt", time() - 36000, "/");
die();
}
}
public function setEncryptedCookie($value){
@@ -176,5 +181,19 @@ class UserManager
die();
}
}
public function changePassword($oldPassword, $newPassword, $newPassword2){
if ($newPassword == $newPassword2) {
//Password Criteria
$oldPasswordSaved = self::getUserData('password');
if (self::getHashPassword($oldPassword) == $oldPasswordSaved) {
self::setUserData('password', self::getHashPassword($newPassword));
} else {
throw new ChybaUzivatele ("old password did not match");
}
} else {
throw new ChybaUzivatele ("new password arent same");
}
}
}
?>