ce souvenir lors de la connexion
This commit is contained in:
parent
42a41e5359
commit
0c6088d4da
5 changed files with 61 additions and 6 deletions
|
|
@ -70,6 +70,27 @@
|
|||
return $rqPrep->execute();
|
||||
}
|
||||
|
||||
public function remember(int $userId, string $token):bool{
|
||||
$strRq = "INSERT INTO tokens (token_user_id, token_hash, token_created_at, token_expire_at) VALUES (:id, :token, NOW(), :exp)";
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
$rqPrep->bindValue(":id", $userId, PDO::PARAM_INT);
|
||||
$rqPrep->bindValue(":token", $token, PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":exp",
|
||||
//pour faire que le cookies soit valable 1 jours
|
||||
date('Y-m-d H:i:s', time() + (24*60*60))
|
||||
, PDO::PARAM_STR);
|
||||
return $rqPrep->execute();
|
||||
|
||||
}
|
||||
public function getTokenUser(string $hash){
|
||||
$strRq = $this->_db->prepare("SELECT token_user_id FROM tokens WHERE token_hash = :hash AND expires_at > NOW()");
|
||||
return $strRq->execute(['hash' => $hash]);
|
||||
}
|
||||
public function deleteToken(string $hash){
|
||||
$stmt = $this->_db->prepare("DELETE FROM tokens WHERE token_hash = :hash");
|
||||
$stmt->execute(['hash' => $hash]);
|
||||
}
|
||||
|
||||
public function update(object $objUser):bool{
|
||||
$strRq = "UPDATE users SET
|
||||
user_name = :name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue