summaryrefslogtreecommitdiff
path: root/public/app/controllers
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
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')
-rw-r--r--public/app/controllers/Auth.php10
-rw-r--r--public/app/controllers/cms/Course.php4
2 files changed, 10 insertions, 4 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;
diff --git a/public/app/controllers/cms/Course.php b/public/app/controllers/cms/Course.php
index 0edc832..a1de9c1 100644
--- a/public/app/controllers/cms/Course.php
+++ b/public/app/controllers/cms/Course.php
@@ -31,7 +31,7 @@ class Course {
*
* @return true|false
*/
- private static function is_admin_or_permited( $privilege_id)
+ private static function is_admin_or_permited( $privilege_id )
{
return (
Auth::in_admin_group()
@@ -56,7 +56,7 @@ class Course {
$file = self::get_file_attributes($file_path);
// if user is authorized
- if (is_admin_or_permited($file['privilege_id'])) {
+ if (self::is_admin_or_permited($file['privilege_id'])) {
$media_type = Registry::get('REQUEST')->GET['type']; // get media-type
$real_path = MEDIA_STORAGE_ROOT . $file_path; // construct real path