Skip to content

Commit

Permalink
Merge pull request #842 from alphagov/sign-in-route
Browse files Browse the repository at this point in the history
Check content item is a sign in page before attempting to sign in
  • Loading branch information
thomasleese authored Mar 21, 2018
2 parents c1afd34 + 91d0296 commit 5215df7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/controllers/content_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def show
end

def service_sign_in_options
return head :not_found unless is_sign_in_content_item_path?

if params[:option].blank?
@error = true
show
Expand All @@ -35,6 +37,10 @@ def service_sign_in_options

private

def is_sign_in_content_item_path?
content_item_path.include?("sign-in")
end

# Allow guides to pass access token to each part to allow
# fact checking of all content
def set_guide_draft_access_token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class ContentItemsControllerTest < ActionController::TestCase
end


test "raises a 404 for a content item which isn't a service_sign_in page" do
path = "this/is/not/a/sign/in/page"
post :service_sign_in_options, params: { path: path }
assert_response :not_found
end

test "service_sign_in_options with option param set" do
content_item = content_store_has_schema_example("service_sign_in", "service_sign_in")
Expand Down

0 comments on commit 5215df7

Please sign in to comment.