Add auth in all controllers

This commit is contained in:
sto
2025-03-22 13:07:12 +01:00
parent 5472a400d1
commit 6b02eecb9b
11 changed files with 107 additions and 6 deletions

View File

@@ -3,15 +3,21 @@ class PuzzlesController < ApplicationController
before_action :set_puzzle, only: %i[ destroy edit update]
def edit
authorize @contest
@title = "Edit contest puzzle"
end
def new
authorize @contest
@puzzle = Puzzle.new
@title = "New contest puzzle"
end
def create
authorize @contest
@puzzle = Puzzle.new(puzzle_params)
@puzzle.contest_id = @contest.id
if @puzzle.save
@@ -23,6 +29,8 @@ class PuzzlesController < ApplicationController
end
def update
authorize @contest
if @puzzle.update(puzzle_params)
redirect_to @contest
else
@@ -32,6 +40,8 @@ class PuzzlesController < ApplicationController
end
def destroy
authorize @contest
@puzzle.destroy
redirect_to contest_path(@contest)
end