Skip to content

Commit

Permalink
Merge pull request #29 from cabinetoffice/downing-fix
Browse files Browse the repository at this point in the history
Fixes issues for those on No.10 platforms
  • Loading branch information
lukesands-co committed Mar 17, 2016
2 parents 65795a0 + cec8468 commit 044edb9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
12 changes: 10 additions & 2 deletions app/models/email_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@ def valid_address?
end

def inferred_last_name
capitalise(local.split('.')[(multipart_local? ? 1 : 0)])
if domain.end_with? "no10.x.gsi.gov.uk"
capitalise(local[1..-1])
else
capitalise(local.split('.')[(multipart_local? ? 1 : 0)])
end
end

def inferred_first_name
capitalise(local.split('.')[0]) if multipart_local?
if domain.end_with? "no10.x.gsi.gov.uk"
capitalise(local[0])
else
capitalise(local.split('.')[0]) if multipart_local?
end
end

def multipart_local?
Expand Down
16 changes: 13 additions & 3 deletions app/views/sessions/failed.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
%h1.visuallyhidden= @page_title = 'Login failure'
%h2.h3.no-line You need to log in with a Cabinet Office email address
%p= link_to 'Return to the log in screen', '/'
- content_for :body_classes, 'failed-page'

%h1.no-line Sorry, that didn't work

%h2.h3.no-line We couldn't verify your details, so we couldn't log you in.

%p It might be that you haven't logged in using your Cabinet Office email address, or perhaps something else isn't right.

.spacer-5
.spacer-5
.spacer-5

%p= link_to 'Go back', '/', class: 'button login-button'
6 changes: 5 additions & 1 deletion config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Be sure to restart your server when you modify this file.

Rails.application.config.session_store :cookie_store, key: '_moj_peoplefinder_session'
if Rails.env.production? or Rails.env.staging?
Rails.application.config.session_store :cookie_store, :key => '_co_peoplefinder_session', :domain => 'peoplefinder.cabinetoffice.gov.uk'
else
Rails.application.config.session_store :cookie_store, :key => '_co_peoplefinder_session'
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
resources :tokens, only: [:create, :destroy, :show]

match '/auth/:provider/callback', to: 'sessions#create', via: [:get, :post]
match '/auth/failure', to: 'sessions#failed', via: [:get, :post]
match '/audit_trail', to: 'versions#index', via: [:get]
match '/audit_trail/undo/:id', to: 'versions#undo', via: [:post]
match '/search', to: 'search#index', via: [:get]
Expand Down
6 changes: 3 additions & 3 deletions spec/features/omni_auth_authentication_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
expect(login_page).to be_displayed

click_link 'Log in'
expect(page).to have_title("Login failure - #{ app_title }")
expect(page).to have_text(/log in with a Cabinet Office email address/)
expect(page).to have_title("#{ app_title }")
expect(page).to have_text(/We couldn't verify your details, so we couldn't log you in./)

click_link 'Return to the log in screen'
click_link 'Go back'
expect(login_page).to be_displayed
end

Expand Down

0 comments on commit 044edb9

Please sign in to comment.