Skip to content

Commit

Permalink
Fix crash in /submissions/my when not signed in
Browse files Browse the repository at this point in the history
We need to check that we have a current user before using
current_user.id.

Error trace:

```
NoMethodError (undefined method `id' for nil:NilClass):
  app/controllers/submissions_controller.rb:19:in `index'
```
  • Loading branch information
tom93 committed Jan 8, 2024
1 parent 99b2e7c commit ceb2a98
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def permitted_params
# GET /submissions
# GET /submissions.xml
def index
raise Pundit::NotAuthorizedError if current_user.nil?
params[:by_user] = current_user.id.to_s if params[:filter] == 'my'
if !params[:by_user].nil? && params[:by_user].to_i != current_user.id
authorize User.find(params[:by_user]), :inspect?
Expand Down

0 comments on commit ceb2a98

Please sign in to comment.