summaryrefslogtreecommitdiff
path: root/public/app/controllers/Auth.php
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-26 04:43:12 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-26 04:43:12 +0300
commit9cb35f2bf2127cc8ac077aae17514a57e576217d (patch)
treebf809e73dded8e481d0a2e16c488831052016313 /public/app/controllers/Auth.php
parentb594effb847b86fc6b1dae49d7948c46bba35e58 (diff)
downloadclassroom-9cb35f2bf2127cc8ac077aae17514a57e576217d.tar.gz
classroom-9cb35f2bf2127cc8ac077aae17514a57e576217d.tar.bz2
classroom-9cb35f2bf2127cc8ac077aae17514a57e576217d.zip
alfa.2 version; seceral optimizations; added support for mail-relay
Diffstat (limited to 'public/app/controllers/Auth.php')
-rw-r--r--public/app/controllers/Auth.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/public/app/controllers/Auth.php b/public/app/controllers/Auth.php
index 8af7513..32ff07a 100644
--- a/public/app/controllers/Auth.php
+++ b/public/app/controllers/Auth.php
@@ -52,8 +52,9 @@ class Auth {
// get user's security attributes
$attributes = User_Model::getUser($record['id']);
+ $roles = json_decode($attributes['Roles_json']);
$user
- ->setRoles(json_decode($attributes['Roles_json']))
+ ->setRoles($roles)
->setPrivileges(
array_merge(
json_decode($attributes['RootPrivileges_json']),
@@ -73,10 +74,15 @@ class Auth {
'/'
);
+ // check if admin (and redirect differently)
+ $is_admin = (!empty(array_intersect([1,2,3], $roles)));
// login OK, set Token in session
$userManager->createUserToken($user);
- return true;
+ return [
+ 'success' => true,
+ 'goto' => $is_admin ? '/admin/lessons' : '/user/profile',
+ ];
} else {
return false;