fix teacher attendance
API CI/CD / Validate (composer + pint) (push) Successful in 3m10s
API CI/CD / Test (PHPUnit) (push) Failing after 5m2s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 3m10s
API CI/CD / Test (PHPUnit) (push) Failing after 5m2s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -42,7 +42,9 @@ class TeacherAttendanceApiController extends Controller
|
||||
return new TeacherAttendanceFormResource(
|
||||
$this->queryService->teacherAttendanceFormData(
|
||||
$guard,
|
||||
(int) $request->query('class_section_id', 0)
|
||||
(int) $request->query('class_section_id', 0),
|
||||
$request->query('school_year'),
|
||||
$request->query('semester')
|
||||
)
|
||||
);
|
||||
} catch (Throwable $e) {
|
||||
@@ -68,7 +70,7 @@ class TeacherAttendanceApiController extends Controller
|
||||
|
||||
private function authenticatedUserIdOrUnauthorized(): int|JsonResponse
|
||||
{
|
||||
$userId = (int) (auth()->id() ?? 0);
|
||||
$userId = (int) (auth('api')->id() ?? auth()->id() ?? 0);
|
||||
if ($userId <= 0) {
|
||||
return response()->json(['message' => 'Unauthorized.'], 401);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,19 @@ class MultiAuth
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
try {
|
||||
if ($apiUser = Auth::guard('api')->user()) {
|
||||
Auth::setUser($apiUser);
|
||||
|
||||
if ($response = $this->denyUnavailableAccount($apiUser)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
} catch (\Throwable) {
|
||||
}
|
||||
|
||||
try {
|
||||
$sanctumUser = Auth::guard('sanctum')->user();
|
||||
} catch (\InvalidArgumentException) {
|
||||
@@ -30,19 +43,6 @@ class MultiAuth
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
try {
|
||||
if ($apiUser = Auth::guard('api')->user()) {
|
||||
Auth::setUser($apiUser);
|
||||
|
||||
if ($response = $this->denyUnavailableAccount($apiUser)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
} catch (\Throwable) {
|
||||
}
|
||||
|
||||
$token = $request->bearerToken();
|
||||
if ($token) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user