Skip to content

Commit

Permalink
fix: made events calendar public without auth key
Browse files Browse the repository at this point in the history
  • Loading branch information
blt950 committed Sep 8, 2024
1 parent 34580cd commit cec696c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/Http/Middleware/ApiToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ public function handle(Request $request, Closure $next, $args = ''): Response

if($key === null || ($args == 'edit' && $key->readonly == true))
{
return response()->json([
'message' => 'Unauthorized',
], 401);
// Exception for open calendar fetch
if (preg_match('/^\/api\/calendars\/\d+\/events$/', $request->getRequestUri())) {
$request->attributes->set('unauthenticated', true);
return $next($request);
} else {
return response()->json([
'message' => 'Unauthorized',
], 401);
}
}

$key->update(['last_used_at', now()]);
Expand Down

0 comments on commit cec696c

Please sign in to comment.