Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
Add admin sign in page
Browse files Browse the repository at this point in the history
* Next step is to hook up this button to work
* This provides a skeleton page + test
  • Loading branch information
jessieay committed Jan 11, 2017
1 parent 96293a5 commit b84fc95
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 8 deletions.
3 changes: 3 additions & 0 deletions app/controllers/admin/sign_ins_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Admin::SignInsController < ApplicationController
def show; end
end
6 changes: 5 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
6 changes: 1 addition & 5 deletions app/controllers/saml_authentications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 17 additions & 0 deletions app/views/admin/sign_ins/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<% content_for :title do %>18F Micro-purchase - Admin Login<% end %>

<div class="usa-grid">
<div class="usa-width-one-half">
<h1>Admin sign in</h1>
<p>
<%= link_to 'Authorize with GitHub',
'/auth/github',
class: 'usa-button usa-button usa-button-outline' %>
</p>
<div class="mb1 right-align login_gov">
<button type="submit" class="btn btn-outline bg-white navy">
Authorize with Login.gov
</button>
</div>
</div>
</div>
3 changes: 1 addition & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
mount LetterOpenerWeb::Engine => "letter_opener"
end

# Web requests

root 'auctions#index'

get '/auth/github/callback', to: 'authentications#create'
Expand All @@ -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'

Expand Down
4 changes: 4 additions & 0 deletions features/admin_signs_in.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions features/step_definitions/navigation_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b84fc95

Please sign in to comment.