Add auth in all controllers
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user