[#917] redirect to correct location after login with france connect
This commit is contained in:
parent
ddc1052daf
commit
afed93247d
6 changed files with 42 additions and 9 deletions
|
@ -28,7 +28,8 @@ class FranceConnectController < ApplicationController
|
||||||
@user.save
|
@user.save
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to(controller: 'users/dossiers', action: :index)
|
redirect_to stored_location_for(current_user) || signed_in_root_path(current_user)
|
||||||
|
|
||||||
end
|
end
|
||||||
rescue Rack::OAuth2::Client::Error => e
|
rescue Rack::OAuth2::Client::Error => e
|
||||||
Rails.logger.error e.message
|
Rails.logger.error e.message
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%h1 Vos dossiers :
|
%h1#users_dossiers_index Vos dossiers :
|
||||||
|
|
||||||
%table.table
|
%table.table
|
||||||
%thead
|
%thead
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.container.center
|
.container.center#users_siret_index
|
||||||
%h1.cover-heading <b>T</b>élé<b>P</b>rocédure administrative <b>S</b>implifiée
|
%h1.cover-heading <b>T</b>élé<b>P</b>rocédure administrative <b>S</b>implifiée
|
||||||
%br
|
%br
|
||||||
%p{style: 'width:67%; margin-left:auto; margin-right:auto'}
|
%p{style: 'width:67%; margin-left:auto; margin-right:auto'}
|
||||||
|
|
|
@ -44,8 +44,8 @@ ActiveRecord::Schema.define(version: 20151007085022) do
|
||||||
t.string "montant_aide_demande"
|
t.string "montant_aide_demande"
|
||||||
t.integer "procedure_id"
|
t.integer "procedure_id"
|
||||||
t.date "date_previsionnelle"
|
t.date "date_previsionnelle"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", default: '2015-09-22 09:25:29'
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", default: '2015-09-22 09:25:29'
|
||||||
t.string "state"
|
t.string "state"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,14 +33,15 @@ describe FranceConnectController, type: :controller do
|
||||||
it 'login_with_france_connect user attribut is true' do
|
it 'login_with_france_connect user attribut is true' do
|
||||||
expect(current_user.login_with_france_connect).to be_truthy
|
expect(current_user.login_with_france_connect).to be_truthy
|
||||||
end
|
end
|
||||||
|
let(:stored_location) { '/plip/plop' }
|
||||||
it 'redirect to dossiers list' do
|
it 'redirect to stored location' do
|
||||||
|
subject.store_location_for(:user, stored_location)
|
||||||
get :callback, code: code
|
get :callback, code: code
|
||||||
expect(response).to redirect_to(controller: 'users/dossiers', action: :index)
|
expect(response).to redirect_to(stored_location)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'wen code is not correct' do
|
context 'when code is not correct' do
|
||||||
before do
|
before do
|
||||||
allow(FranceConnectService).to receive(:retrieve_user_informations) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
|
allow(FranceConnectService).to receive(:retrieve_user_informations) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
|
||||||
get :callback, code: code
|
get :callback, code: code
|
||||||
|
|
|
@ -44,4 +44,35 @@ feature 'France Connect Connexion' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
feature 'redirection' do
|
||||||
|
before do
|
||||||
|
visit initial_path
|
||||||
|
end
|
||||||
|
context 'when he use france connect' do
|
||||||
|
let(:code) { 'my_code' }
|
||||||
|
let(:email) { 'plop@plop.com' }
|
||||||
|
let(:siret) { '00000000000000' }
|
||||||
|
let(:user_infos) { Hashie::Mash.new(email: email, siret: siret) }
|
||||||
|
before do
|
||||||
|
allow_any_instance_of(FranceConnectClient).to receive(:authorization_uri).and_return(france_connect_callback_path(code: code))
|
||||||
|
allow(FranceConnectService).to receive(:retrieve_user_informations).and_return(user_infos)
|
||||||
|
page.find_by_id('france_connect').click
|
||||||
|
end
|
||||||
|
context 'when starting page is dossiers list' do
|
||||||
|
let(:initial_path) { users_dossiers_path }
|
||||||
|
scenario 'he is redirected to dossier list' do
|
||||||
|
expect(page).to have_css('#users_dossiers_index')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
context 'when starting page is procedure' do
|
||||||
|
let(:procedure) { create(:procedure) }
|
||||||
|
let(:initial_path) { users_siret_path(procedure_id: procedure.id ) }
|
||||||
|
scenario 'he is redirected to siret page' do
|
||||||
|
expect(page).to have_css('#users_siret_index')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in a new issue