Base application
[infodrom.org/touren.infodrom.org] / core / sys_user.class.php
diff --git a/core/sys_user.class.php b/core/sys_user.class.php
new file mode 100644 (file)
index 0000000..c03b23a
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+class Sys_User extends DatabaseTable
+{
+    public function __construct($id=false, $column=false)
+    {
+       parent::__construct('sys_user', $id, $column);
+    }
+
+    public function generateKey()
+    {
+       $key = md5(random_bytes(20));
+
+       $this->modify(['pwkey' => $key,
+                      'pwkey_valid' => 'now()']);
+    }
+
+    public function setPassword($passwd)
+    {
+       return $this->modify(['passwd' => md5($this->data->email.$passwd),
+                             'pwkey' => NULL,
+                             'pwkey_valid' => NULL]);
+    }
+}