fix parent, teacher and admin pages

This commit is contained in:
root
2026-04-25 00:00:23 -04:00
parent 4cd98f1d30
commit eafe4eb134
30 changed files with 1566 additions and 105 deletions
@@ -116,12 +116,13 @@ class ApiLoginSecurityService
/**
* Top-level JSON body aligned with the CodeIgniter 4 `AuthController::apiLogin` success payload.
*
* @return array{status: true, token: string, user: array{id: int, name: string, roles: object}}
* @return array{status: true, token: string, user: array{id: int, name: string, roles: object, class_section_id: ?int, class_section_name: ?string}}
*/
public function buildLoginResponse(User $user, string $jwtToken): array
{
$roleNames = $user->roleNamesLikeCodeIgniter();
$fullName = trim(($user->firstname ?? '').' '.($user->lastname ?? ''));
$teacherContext = $user->teacherSessionContext();
return [
'status' => true,
@@ -130,6 +131,8 @@ class ApiLoginSecurityService
'id' => (int) $user->id,
'name' => $fullName,
'roles' => $this->rolesToObjectMap($roleNames),
'class_section_id' => $teacherContext['class_section_id'],
'class_section_name' => $teacherContext['class_section_name'],
],
];
}
+3
View File
@@ -124,6 +124,7 @@ class AuthSessionService
$schoolYear = Configuration::getConfig('school_year');
$semester = Configuration::getConfig('semester');
$teacherContext = $user->teacherSessionContext();
session([
'user_id' => $user->id,
@@ -136,6 +137,8 @@ class AuthSessionService
'roles' => $roleNames,
'semester' => $semester,
'school_year' => $schoolYear,
'class_section_id' => $teacherContext['class_section_id'],
'class_section_name' => $teacherContext['class_section_name'],
]);
$this->applyStylePreferencesToSession((int) $user->id);