aboutsummaryrefslogtreecommitdiff
path: root/app/class/Modelauthtoken.php
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-04-08 20:50:50 +0200
committervincent-peugnet <v.peugnet@free.fr>2020-04-08 20:50:50 +0200
commitc35d018995da99028747fe672e4d07484855dba2 (patch)
treeed509e89b2d5f5c63d0af7580360e6eacea0fb7b /app/class/Modelauthtoken.php
parentc3e62c500b38104acaecc987621cfc03058729c0 (diff)
downloadwcms-c35d018995da99028747fe672e4d07484855dba2.tar.gz
wcms-c35d018995da99028747fe672e4d07484855dba2.zip
simple cookies storage
using flywheel autogerated ID
Diffstat (limited to 'app/class/Modelauthtoken.php')
-rw-r--r--app/class/Modelauthtoken.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/app/class/Modelauthtoken.php b/app/class/Modelauthtoken.php
new file mode 100644
index 0000000..0a55e64
--- /dev/null
+++ b/app/class/Modelauthtoken.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace Wcms;
+
+use JamesMoss\Flywheel\Document;
+
+class Modelauthtoken extends Modeldb
+{
+
+ const AUTHTOKEN_REPO_NAME = 'authtoken';
+
+
+ public function __construct()
+ {
+ parent::__construct();
+ $this->storeinit(self::AUTHTOKEN_REPO_NAME);
+ }
+
+ /**
+ * Add a Token in the database according to the Users datas
+ *
+ * @param User $user
+ */
+ public function add(User $user)
+ {
+ $datas = [
+ 'user' => $user->id(),
+ 'ip' => $_SERVER['SERVER_ADDR'],
+ 'creationdate' => '1'
+ ];
+ $tokendata = new Document($datas);
+ return $this->repo->store($tokendata);
+
+ }
+
+ public function getbytoken(string $token)
+ {
+ return $this->repo->findById($token);
+ }
+
+ public function delete(string $token)
+ {
+ return $this->repo->delete($token);
+ }
+
+}
+
+
+
+
+
+
+?> \ No newline at end of file