diff options
Diffstat (limited to 'public/app/controllers/Auth.php')
| -rw-r--r-- | public/app/controllers/Auth.php | 10 |
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; |
