diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-27 21:12:02 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-27 21:12:02 +0500 |
| commit | 9f1906c4cbb9878c5888723b7923fa8e4bebb51f (patch) | |
| tree | 25f838ee0bb91f2a14d061906dde96967dd72a95 /src/accounts.php | |
| parent | 00ab9aeaf0eac4c82e6480faee70add916db514f (diff) | |
feat: roles
Diffstat (limited to 'src/accounts.php')
| -rw-r--r-- | src/accounts.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/accounts.php b/src/accounts.php index 87c8ef0..f97998a 100644 --- a/src/accounts.php +++ b/src/accounts.php @@ -41,6 +41,19 @@ function authorize_user(bool $required = false): bool $stmt = $db->prepare("UPDATE users SET last_active_at = UTC_TIMESTAMP WHERE id = ?"); $stmt->execute([$row["id"]]); + + // fetching role + $stmt = $db->prepare("SELECT * FROM roles r + INNER JOIN role_assigns ra ON ra.user_id = ? + WHERE r.id = ra.role_id + "); + $stmt->execute([$row["id"]]); + + $_SESSION["user_role"] = null; + + if ($role_row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $_SESSION["user_role"] = $role_row; + } } else { session_regenerate_id(); session_unset(); @@ -61,5 +74,6 @@ function authorize_user(bool $required = false): bool } $db = null; + $stmt = null; return isset($_SESSION["user_name"]); }
\ No newline at end of file |
