Skip to content

Commit

Permalink
Add admin authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
alvp01 committed Dec 15, 2023
1 parent b2e2e1c commit 65b79ed
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/controllers/api/games_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ def show

def create
@game = Game.new(game_params)
user = User.find(params[:user_id])

if current_user.is_admin && @game.save
if user.is_admin && @game.save
render json: @game, status: :created
else
render json: @game.errors, status: :unprocessable_entity
end
end

def destroy
if current_user.is_admin && @game.destroy
if @game.destroy
head :no_content
else
render json: @game.errors, status: :unprocessable_entity
Expand Down

0 comments on commit 65b79ed

Please sign in to comment.