diff options
author | Camil Staps | 2016-07-26 14:27:14 +0200 |
---|---|---|
committer | Camil Staps | 2016-07-26 14:27:14 +0200 |
commit | d8055192991ac8504e48c137038879790c762d2d (patch) | |
tree | 0738603efca98c26d6d04cbd091898d4b6e9a34d /classes/user.php | |
parent | Option to add first user during installation (diff) |
Adding and deleting users
Diffstat (limited to 'classes/user.php')
-rw-r--r-- | classes/user.php | 19 |
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 |