diff options
author | Simon Rettberg | 2023-11-28 13:57:59 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-11-28 13:57:59 +0100 |
commit | 2cc01cd304a2c027f9183221acc6e61bfbe51f00 (patch) | |
tree | 45487447886691dc679c2cc4dbd2aaea4708921c | |
parent | [inc/Render] Why not go ahead and user the according output handler (diff) | |
download | bwlp-webadmin-2cc01cd304a2c027f9183221acc6e61bfbe51f00.tar.gz bwlp-webadmin-2cc01cd304a2c027f9183221acc6e61bfbe51f00.tar.xz bwlp-webadmin-2cc01cd304a2c027f9183221acc6e61bfbe51f00.zip |
More type annotations
-rw-r--r-- | inc/user.inc.php | 26 | ||||
-rw-r--r-- | modules/main.inc.php | 2 | ||||
-rw-r--r-- | modules/register.inc.php | 4 |
3 files changed, 16 insertions, 16 deletions
diff --git a/inc/user.inc.php b/inc/user.inc.php index bc07f5d..9520640 100644 --- a/inc/user.inc.php +++ b/inc/user.inc.php @@ -14,27 +14,27 @@ class User return self::$user !== null; } - public static function isShibbolethAuth() + public static function isShibbolethAuth(): bool { return self::$isShib; } - public static function isInDatabase() + public static function isInDatabase(): bool { return self::$isInDb; } - public static function isLocalOnly() + public static function isLocalOnly(): bool { return self::$user !== null && self::$isShib === false; } - public static function isAnonymous() + public static function isAnonymous(): bool { return self::$isAnonymous; } - public static function getData() + public static function getData(): ?array { return self::$user; } @@ -79,7 +79,7 @@ class User return self::$user !== null && !empty(self::$user['firstname']) && !empty(self::$user['lastname']); } - public static function isTutor() + public static function isTutor(): bool { return isset(self::$user['role']) && self::$user['role'] === 'TUTOR'; } @@ -147,7 +147,7 @@ class User return self::$user['shibid']; } - public static function load() + public static function load(): bool { //file_put_contents('/tmp/test-' . time(), print_r($_SERVER, true)); if (self::isLoggedIn()) @@ -246,7 +246,7 @@ class User return true; } - public static function deploy(bool $anonymous, $existingLogin = false): bool + public static function deploy(bool $anonymous, ?string $existingLogin = null): bool { if (empty(self::$user['shibid'])) Util::traceError('NO SHIBID'); @@ -299,7 +299,7 @@ class User return true; } - public static function updatePassword($pass) + public static function updatePassword(string $pass): bool { if (!self::isLoggedIn() || self::$isShib || !self::$isInDb) return false; @@ -311,7 +311,7 @@ class User return $ret == 1; } - public static function updateMail($mail) + public static function updateMail(string $mail): bool { if (!self::isLoggedIn() || self::$isShib || !self::$isInDb) return false; @@ -322,7 +322,7 @@ class User return $ret == 1 || $mail === self::$user['email']; } - public static function login($user, $pass) + public static function login(string $user, string $pass): bool { $ret = Database::queryFirst('SELECT userid, password FROM user WHERE userid = :user LIMIT 1', array(':user' => $user)); if ($ret === false) @@ -336,7 +336,7 @@ class User return true; } - public static function logout() + public static function logout(): never { foreach ($_COOKIE as $name => $value) { if (substr($name, 0, 5) !== '_shib') @@ -352,7 +352,7 @@ class User exit(0); } - public static function delete() + public static function delete(): bool { if (!User::isLoggedIn() || !User::isInDatabase()) return true; diff --git a/modules/main.inc.php b/modules/main.inc.php index 3b605a3..40aa87d 100644 --- a/modules/main.inc.php +++ b/modules/main.inc.php @@ -89,7 +89,7 @@ class Page_Main extends Page Render::addTemplate('main/deploy', $data); } - private function renderLocalAccount() + private function renderLocalAccount(): void { $data = User::getData(); $data['organization'] = User::getOrganizationName(); diff --git a/modules/register.inc.php b/modules/register.inc.php index f55e900..98e8763 100644 --- a/modules/register.inc.php +++ b/modules/register.inc.php @@ -26,9 +26,9 @@ class Page_Register extends Page $anonymous = (Request::post('share') !== 'on'); $testLogin = Request::post('testlogin'); if (empty($testLogin)) { - $testLogin = false; + $testLogin = null; } - if ($testLogin !== false) { + if ($testLogin !== null) { // Check if one of firstname, lastname or email matches $user = Database::queryFirst('SELECT firstname, lastname, email, password, organizationid FROM user WHERE userid = :login LIMIT 1', array('login' => $testLogin)); |