diff --git a/app/controllers/admin/sign_ins_controller.rb b/app/controllers/admin/sign_ins_controller.rb new file mode 100644 index 00000000..1d32e32b --- /dev/null +++ b/app/controllers/admin/sign_ins_controller.rb @@ -0,0 +1,3 @@ +class Admin::SignInsController < ApplicationController + def show; end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a7ada9bd..ddfe03b6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -20,7 +20,11 @@ class ApplicationController < ActionController::Base rescue_from 'UnauthorizedError::RedirectToLogin' do store_location - redirect_to sign_in_path + if store_location == "/admin" + redirect_to admin_sign_in_path + else + redirect_to sign_in_path + end end rescue_from 'UnauthorizedError::UserNotFound' do |error| diff --git a/app/controllers/saml_authentications_controller.rb b/app/controllers/saml_authentications_controller.rb index d473ca23..81889ac0 100644 --- a/app/controllers/saml_authentications_controller.rb +++ b/app/controllers/saml_authentications_controller.rb @@ -4,11 +4,7 @@ def create if user session[:user_id] = user.id - - redirect_to( - admin_path, - notice: t('omniauth_callbacks.success') - ) + redirect_to admin_path, notice: t('omniauth_callbacks.success') else redirect_to( root_path, diff --git a/app/views/admin/sign_ins/show.html.erb b/app/views/admin/sign_ins/show.html.erb new file mode 100644 index 00000000..59cd2b69 --- /dev/null +++ b/app/views/admin/sign_ins/show.html.erb @@ -0,0 +1,17 @@ +<% content_for :title do %>18F Micro-purchase - Admin Login<% end %> + +
+
+

Admin sign in

+

+ <%= link_to 'Authorize with GitHub', + '/auth/github', + class: 'usa-button usa-button usa-button-outline' %> +

+ +
+
diff --git a/config/routes.rb b/config/routes.rb index 53a38ec6..c8ce031b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,8 +3,6 @@ mount LetterOpenerWeb::Engine => "letter_opener" end - # Web requests - root 'auctions#index' get '/auth/github/callback', to: 'authentications#create' @@ -18,6 +16,7 @@ get '/auctions/rules/sealed-bid', to: 'auctions#sealed_bid_auction_rules' get '/auctions/rules/reverse', to: 'auctions#reverse_auction_rules' get '/admin', to: 'admin/auctions/needs_attention#index' + get '/admin/sign_in', to: 'admin/sign_ins#show' get '/sign_up', to: 'sign_ups#show' get '/sign_in', to: 'sign_ins#show' diff --git a/features/admin_signs_in.feature b/features/admin_signs_in.feature index 839eca05..a89926e4 100644 --- a/features/admin_signs_in.feature +++ b/features/admin_signs_in.feature @@ -6,3 +6,7 @@ Feature: Admin signs in Given I am an administrator And I sign in Then I should be on the admin needs attention auctions page + + Scenario: Logged out admin tries to visit admin path + When I visit the admin page + Then I should on the admin login page diff --git a/features/step_definitions/navigation_steps.rb b/features/step_definitions/navigation_steps.rb index c432c0f9..453973cf 100644 --- a/features/step_definitions/navigation_steps.rb +++ b/features/step_definitions/navigation_steps.rb @@ -153,3 +153,7 @@ Then(/^I should be on the rules page for sealed-bid auctions$/) do expect(page.current_path).to eq('/auctions/rules/sealed-bid') end + +Then(/^I should on the admin login page$/) do + expect(page.current_path).to eq(admin_sign_in_path) +end