From 9cb35f2bf2127cc8ac077aae17514a57e576217d Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Wed, 26 Apr 2023 04:43:12 +0300 Subject: alfa.2 version; seceral optimizations; added support for mail-relay --- public/app/controllers/Auth.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'public/app/controllers/Auth.php') 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; -- cgit v1.2.3