-
Notifications
You must be signed in to change notification settings - Fork 0
IIRR-30 | IIRR-31: Fix auth bug and enable puzzle cloning #62
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
base: main
Are you sure you want to change the base?
Conversation
3f377f8 to
529a964
Compare
| # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. | ||
| allow_browser versions: :modern | ||
| before_action :check_session_expiry | ||
| before_action :check_user_token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure user is authenticated in all controllers that inherit from ApplicationController
| @@ -42,6 +42,7 @@ | |||
| <%= button_to 'Pending', puzzle_state_path(puzzle, state: :pending), method: :patch, form_class: 'inline-form', class: 'btn pending-btn' %> | |||
| <% elsif actions == :archived %> | |||
| <%= button_to 'Un-Archive', puzzle_state_path(puzzle, state: :pending), method: :patch, form_class: 'inline-form', class: 'btn pending-btn' %> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to keep the Un-Archive button?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should since clone is being added, so we do not have to use un-archive.
| def create | ||
| original_puzzle = Puzzle.find(params[:puzzle_id]) | ||
| attributes = original_puzzle.attributes.slice("question", "answer", "explanation", "link", "suggested_by") | ||
| cloned_puzzle = Puzzle.new(attributes.merge(state: params.fetch(:state, "pending"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can clone and assign any state, defaults to pending.
| <%= button_to 'Pending', puzzle_state_path(puzzle, state: :pending), method: :patch, form_class: 'inline-form', class: 'btn pending-btn' %> | ||
| <% elsif actions == :archived %> | ||
| <%= button_to 'Un-Archive', puzzle_state_path(puzzle, state: :pending), method: :patch, form_class: 'inline-form', class: 'btn pending-btn' %> | ||
| <%= button_to 'Clone', puzzle_clone_path(puzzle, state: :pending), method: :post, form_class: 'inline-form', class: 'btn pending-btn' %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cloned puzzled state can be set here.
Add a before_action in ApplicationController to check for the presence of a user token in the session, rendering the login page if missing. Remove redundant token check from PuzzlesController. Allow SessionsController to skip this check for authentication purposes. Ref: https://ombulabs.atlassian.net/browse/IIRR-30
Implement a clone action in Puzzles::ClonesController to duplicate existing puzzles. Add a "Clone" button to the archived puzzles table. Include tests for cloning functionality and authentication checks. Ref: https://ombulabs.atlassian.net/browse/IIRR-31
529a964 to
d8bf90d
Compare
| user_email = auth.info.email | ||
|
|
||
| domain_allowlist = ENV.fetch("DOMAIN_ALLOWLIST").split(",").map(&:strip) | ||
| domain_allowlist = ENV.fetch("DOMAIN_ALLOWLIST", "").split(",").map(&:strip) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix a CI failure where DOMAIN_ALLOWLIST is not defined.
rishijain
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes LGTM 🚀 . If you do decide to remove the un-archive in this PR itself, lemme know and I can take a look again once you do. Otherwise this PR is good to go.
Added skip_before_action :check_user_token to Slack::ApplicationController to bypass user token verification for Slack requests. This ensures that Slack webhooks and interactions are not blocked by user authentication requirements. Ref: https://ombulabs.atlassian.net/browse/IIRR-30
3f56c9e to
38ceffe
Compare
| @@ -1,5 +1,7 @@ | |||
| class Slack::ApplicationController < ApplicationController | |||
| skip_before_action :verify_authenticity_token | |||
| skip_before_action :check_user_token | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slack controllers don't relay on omniauth credentials.
| autoprefixer-rails (>= 5.2.1) | ||
| sassc (>= 2.0.0) | ||
| brakeman (7.1.0) | ||
| brakeman (8.0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For CI to pass
Added original_puzzle association to Puzzle model and migration to support tracking the source of cloned puzzles. Updated clone controller and tests to set and verify original_puzzle_id on clone creation. Will be handy when we want to calculate how many people got it right or wrong, if we ever want to show stats for the puzzles. Ref: https://ombulabs.atlassian.net/browse/IIRR-31
IIRR-30(auth): Enforce user token check on all controllers
IIRR-31(puzzles): Add clone action for puzzles
QA Notes
/puzzles/3/editfor example)Jira