aboutsummaryrefslogtreecommitdiff
path: root/classes/user.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/user.php')
-rw-r--r--classes/user.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/classes/user.php b/classes/user.php
index e50f773..750e8bb 100644
--- a/classes/user.php
+++ b/classes/user.php
@@ -34,6 +34,16 @@ class user {
protected $pdo, $id, $username, $password;
/**
+ * Generate a random password
+ *
+ * @return string The password
+ */
+ public static function generateRandomPassword() {
+ return preg_replace('/[^\w]/', '',
+ base64_encode(bin2hex(openssl_random_pseudo_bytes(4))));
+ }
+
+ /**
* Hash a password
*
* @param string $password The password to be hashed
@@ -141,6 +151,15 @@ class user {
//------------------------------------------------------------------------------
/**
+ * Check if a user has administrator rights
+ *
+ * @return bool True iff the user has administrator rights
+ */
+ public function isAdmin() {
+ return $this->getId() == 1;
+ }
+
+ /**
* Verify a password
*
* @param string $password The password to verify