Skip to content

Commit

Permalink
only allow event managers to view future events
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed Feb 1, 2025
1 parent d1c5576 commit 2681fd2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/Filament/Resources/EventResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static function form(Form $form): Form
->schema([
Forms\Components\TextInput::make('Title')
->label('Title')
->unique()
->unique(ignoreRecord: true)
->required()
->minLength(2)
->maxLength(80),
Expand All @@ -135,7 +135,7 @@ public static function form(Form $form): Form
->rules(['alpha_dash'])
->minLength(4)
->maxLength(20)
->unique()
->unique(ignoreRecord: true)
->required()
->columnSpan(2),

Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Resources/EventResource/Pages/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function handleRecordCreation(array $data): Model
// these fields don't actually exist on the event record. don't pass to create().
$numberOfAchievements = (int) $data['numberOfAchievements'];
unset($data['numberOfAchievements']);
$user_id = $data['user_id'];
$user_id = (int) $data['user_id'];
unset($data['user_id']);

// create the event record
Expand Down
7 changes: 7 additions & 0 deletions resources/views/pages-legacy/gameInfo.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@
$isFullyFeaturedGame = System::isGameSystem($gameData['ConsoleID']);
$isEventGame = $gameData['ConsoleID'] == System::Events;
// future events can only be viewed by users who can manage events.
if ($isEventGame && $gameModel->event?->active_from != null
&& $gameModel->event->active_from > Carbon::now()
&& !$userModel?->can('manage', $gameModel->event)) {
abort(401);
}
$pageTitle = "$gameTitle ($consoleName)";
$unlockedAchievements = array_filter($achievementData, function ($achievement) {
Expand Down

0 comments on commit 2681fd2

Please sign in to comment.