diff options
| author | Syndamia <kamen@syndamia.com> | 2025-02-08 17:11:59 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-02-08 17:11:59 +0200 |
| commit | 6a3ac35d35e92537438a47eb0441a077a5d791cf (patch) | |
| tree | 54c2cbc03c10ef9c472b92da9437f0e42f80ce62 | |
| parent | 49f25c00fed83be18faa87295fbc58d69cc2c5d8 (diff) | |
| download | nowayforward_human-6a3ac35d35e92537438a47eb0441a077a5d791cf.tar nowayforward_human-6a3ac35d35e92537438a47eb0441a077a5d791cf.tar.gz nowayforward_human-6a3ac35d35e92537438a47eb0441a077a5d791cf.zip | |
feat(cookies): Rework delete into a method and implement fromDBtoken
| -rw-r--r-- | controllers/session.php | 3 | ||||
| -rw-r--r-- | models/cookies.php | 11 |
2 files changed, 11 insertions, 3 deletions
diff --git a/controllers/session.php b/controllers/session.php index 179afe6..e02cc79 100644 --- a/controllers/session.php +++ b/controllers/session.php @@ -25,7 +25,8 @@ function on_post() { function on_delete() { global $TOKEN; try { - Database\Cookie::delete($TOKEN); + $token = Database\Cookie::fromDBtoken($TOKEN); + $token->delete(); } catch(Exception $e) {} } diff --git a/models/cookies.php b/models/cookies.php index ddc7d1c..b38c5c0 100644 --- a/models/cookies.php +++ b/models/cookies.php @@ -25,10 +25,17 @@ class Cookie extends Table { return User::fromDBuid($UID); } - static function delete(string $token) { + static function fromDBtoken(string $token) : Cookie { + return Table::_fromDB( + "SELECT * FROM Cookies WHERE Token = \"$token\"", + 'Database\Cookie' + ); + } + + function delete() { Table::_delete( 'Cookies', - "Token = \"$token\"" + "Token = \"$this->Token\"" ); } } |
