FIX: update and create_multiple actions missing from requires_login (#37715)

## Summary

`update` and `create_multiple` actions in `InvitesController` were
missing from the `requires_login only:` list, allowing unauthenticated
requests to bypass the `ensure_logged_in` check and reach the action
body.

It's not marked as a security commit as guardians were preventing any
exploit.

## Source

- Patch Triage: https://patch.discourse.org/patch-triage/304
- Original Commit:
https://github.com/discourse/discourse/blob/main/app/controllers/invites_controller.rb

---

🤖 Generated via [Patch Triage](https://patch.discourse.org/patch-triage)
This commit is contained in:
Joffrey JAFFEUX
2026-02-11 12:21:32 +01:00
committed by GitHub
parent b4d485fc1b
commit 4a2f917d33
2 changed files with 14 additions and 2 deletions
+2
View File
@@ -5,6 +5,8 @@ require "csv"
class InvitesController < ApplicationController
requires_login only: %i[
create
create_multiple
update
retrieve
destroy
destroy_all_expired
+12 -2
View File
@@ -628,6 +628,15 @@ RSpec.describe InvitesController do
end
describe "#create-multiple" do
it "requires to be logged in" do
post "/invites/create-multiple.json",
params: {
email: %w[test@example.com test1@example.com],
}
expect(response.status).to eq(403)
expect(response.parsed_body["error_type"]).to eq("not_logged_in")
end
it "fails if you are not admin" do
sign_in(Fabricate(:user))
post "/invites/create-multiple.json",
@@ -817,8 +826,9 @@ RSpec.describe InvitesController do
fab!(:invite) { Fabricate(:invite, invited_by: admin, email: "test@example.com") }
it "requires to be logged in" do
put "/invites/#{invite.id}", params: { email: "test2@example.com" }
expect(response.status).to eq(400)
put "/invites/#{invite.id}.json", params: { email: "test2@example.com" }
expect(response.status).to eq(403)
expect(response.parsed_body["error_type"]).to eq("not_logged_in")
end
context "while logged in" do