Skip to content

Use Identifiable#current_user in API controllers #566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

floehopper
Copy link
Contributor

Previously these were using the @current_user instance variable. However, this was working somewhat by accident, because ApiController#authorize_user (called by a before_action) was calling Identifiable#current_user and thus setting @current_user.

I think it's safer, more idiomatic and less confusing to have an explicit call to the memo-ized Identifiable#current_user. Especially as that's what we're already using in all the other controllers and even in other places in these controllers!

Previously these were using the `@current_user` instance variable.

However, this was working somewhat by accident, because
`ApiController#authorize_user` (called by a `before_action`) was calling
`Identifiable#current_user` and thus setting `@current_user`. I think
it's safer, more idiomatic and less confusing to have an explicit call
to `Identifiable#current_user`.
@cla-bot cla-bot bot added the cla-signed label Jul 8, 2025
@raspberrypiherokubot raspberrypiherokubot temporarily deployed to editor-api-p-fix-curren-q6rjdb July 8, 2025 15:21 Inactive
@floehopper
Copy link
Contributor Author

@adrian-rpf This addresses one of the issues I mentioned when we chatted the other day. I'd welcome your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants