Skip to content

feat: let moderators require a login before attendees can post messages - #245

Open
junkerderprovinz wants to merge 1 commit into
ClaperCo:devfrom
junkerderprovinz:feature/require-login-for-messages
Open

junkerderprovinz wants to merge 1 commit into
ClaperCo:devfrom
junkerderprovinz:feature/require-login-for-messages

Conversation

@junkerderprovinz

@junkerderprovinz junkerderprovinz commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

What it does

Adds a moderator switch to the attendees options, "Require login to post" (keyboard shortcut F), which restricts the message wall to signed-in attendees. Reading messages, reactions, polls, forms and quizzes stay open to everyone.

The switch is a boolean column on presentation_states with a default of false, so existing events and existing posts are unaffected and keep the behaviour they have today.

How it is enforced

Claper.Posts.create_post/3 takes the author as its own argument and puts :user_id on the changeset from it; the field is not cast from the submitted attributes, so a payload naming somebody else's account is ignored. Without an author the changeset is refused when Presentations.authenticated_chat_only?/1 returns true, and that reads the current row from the database rather than a presentation state the caller mounted earlier. The LiveView clause and the composer markup follow the same rule. ClaperWeb.PostController.create/2 answers 422 with the changeset errors; it has no route and always builds a post without an author, so while the setting is on every call to it is refused.

Who may post only means something while messages are on at all, so update_presentation_state/2 refuses a change to anonymous_chat_enabled or authenticated_chat_only while chat_enabled is false. One update that switches messages on and changes who may post in the same push is accepted. The manage view renders both toggles disabled while messages are off and flashes an error if a push arrives regardless.

An attendee without a session gets a log in prompt in place of the composer, pointing at /users/log_in?return_to=/e/<code>, and the identity menu is rendered only with the composer, so it goes away with it. The session controller keeps that parameter only when it is a same origin path, so the link cannot be aimed at another host or at a path that redirect/2 would reject.

Tests cover the context rule, the toggle guard, the gated composer and the return path, including an attendee holding a state loaded before the moderator flipped the switch.

@junkerderprovinz
junkerderprovinz force-pushed the feature/require-login-for-messages branch 4 times, most recently from 4a64d51 to 1a18699 Compare September 11, 2026 17:03
@junkerderprovinz
junkerderprovinz force-pushed the feature/require-login-for-messages branch 2 times, most recently from af4410f to 8d5f4c9 Compare October 2, 2026 01:18
@alxlion alxlion added the enhancement New feature or request label Oct 13, 2026
@junkerderprovinz
junkerderprovinz force-pushed the feature/require-login-for-messages branch from 8d5f4c9 to b4a8371 Compare October 15, 2026 10:51
@junkerderprovinz
junkerderprovinz force-pushed the feature/require-login-for-messages branch 2 times, most recently from 1d451e2 to b617a19 Compare October 28, 2026 22:59
Adds a per-event switch on the attendees options: with it on, only signed-in
attendees can post to the message wall. Everyone can still read, and every
other interaction is unaffected.

The state lives on presentation_states, defaulting to false, so existing
events keep their current behaviour.

The rule is enforced in Claper.Posts: create_attendee_post/3 refuses a
message from an attendee who is not signed in while the event requires a
login, so it holds for every caller rather than only for the rendered
composer. The LiveView clause and the composer markup follow the same rule,
and the disabled composer carries no leftover nickname or identity fields.

Attendees who are not signed in see why the composer is gone and get a log
in link that returns them to the event they came from, checked as a local
path so it cannot be pointed elsewhere.

Turning the switch on or off takes effect for everyone already in the room,
and the moderator's own toggle is refused server-side when the chat is off,
not merely disabled in markup.
@junkerderprovinz
junkerderprovinz force-pushed the feature/require-login-for-messages branch from b617a19 to 1781e39 Compare November 18, 2026 19:20

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants