changement plus coherent
This commit is contained in:
parent
0c6088d4da
commit
1b7527ab66
2 changed files with 8 additions and 7 deletions
|
|
@ -42,7 +42,7 @@ class UserCtrl extends MotherCtrl {
|
||||||
$token_hash = hash('sha256', $token);
|
$token_hash = hash('sha256', $token);
|
||||||
$objUserModel->remember($_SESSION['user']['user_id'],$token_hash);
|
$objUserModel->remember($_SESSION['user']['user_id'],$token_hash);
|
||||||
|
|
||||||
setcookie('remember_me', $token, time() + (24*60*60), "/", "", false, true);
|
setcookie('remember_me', $token, time() + (15*24*60*60), "/", "", true, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
header("Location:index.php");
|
header("Location:index.php");
|
||||||
|
|
|
||||||
|
|
@ -76,19 +76,20 @@
|
||||||
$rqPrep->bindValue(":id", $userId, PDO::PARAM_INT);
|
$rqPrep->bindValue(":id", $userId, PDO::PARAM_INT);
|
||||||
$rqPrep->bindValue(":token", $token, PDO::PARAM_STR);
|
$rqPrep->bindValue(":token", $token, PDO::PARAM_STR);
|
||||||
$rqPrep->bindValue(":exp",
|
$rqPrep->bindValue(":exp",
|
||||||
//pour faire que le cookies soit valable 1 jours
|
//pour faire que le cookies soit valable 15 jours
|
||||||
date('Y-m-d H:i:s', time() + (24*60*60))
|
date('Y-m-d H:i:s', time() + (15*24*60*60))
|
||||||
, PDO::PARAM_STR);
|
, PDO::PARAM_STR);
|
||||||
return $rqPrep->execute();
|
return $rqPrep->execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
public function getTokenUser(string $hash){
|
public function getTokenUser(string $hash){
|
||||||
$strRq = $this->_db->prepare("SELECT token_user_id FROM tokens WHERE token_hash = :hash AND expires_at > NOW()");
|
$strRq = $this->_db->prepare("SELECT token_user_id FROM tokens WHERE token_hash = :hash AND token_expire_at > NOW()");
|
||||||
return $strRq->execute(['hash' => $hash]);
|
$strRq->execute(['hash' => $hash]);
|
||||||
|
return $strRq->fetch();
|
||||||
}
|
}
|
||||||
public function deleteToken(string $hash){
|
public function deleteToken(string $hash){
|
||||||
$stmt = $this->_db->prepare("DELETE FROM tokens WHERE token_hash = :hash");
|
$strRq = $this->_db->prepare("DELETE FROM tokens WHERE token_hash = :hash");
|
||||||
$stmt->execute(['hash' => $hash]);
|
return $strRq->execute(['hash' => $hash]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(object $objUser):bool{
|
public function update(object $objUser):bool{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue