From 80cb8b87fec2767fd0ba8c9d3eea866098f12b92 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 16 Aug 2019 16:47:46 +0200 Subject: [PATCH] Keep only the FC logic and use devise for the rest --- app/controllers/users/sessions_controller.rb | 15 +++------------ .../controllers/users/sessions_controller_spec.rb | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index 3da7fb68f..13f751a42 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -7,24 +7,15 @@ class Users::SessionsController < Devise::SessionsController before_action :restore_procedure_context, only: [:new, :create] - # GET /resource/sign_in - def new - end - # POST /resource/sign_in def create user = User.find_by(email: params[:user][:email]) if user&.valid_password?(params[:user][:password]) - sign_in(user) - current_user.update(loged_in_with_france_connect: nil) - - set_flash_message :notice, :signed_in - redirect_to after_sign_in_path_for(:user) - else - flash.alert = 'Mauvais couple login / mot de passe' - render :new, assigns: { user: User.new } + user.update(loged_in_with_france_connect: nil) end + + super end def link_sent diff --git a/spec/controllers/users/sessions_controller_spec.rb b/spec/controllers/users/sessions_controller_spec.rb index e7c3ac988..6f09382fa 100644 --- a/spec/controllers/users/sessions_controller_spec.rb +++ b/spec/controllers/users/sessions_controller_spec.rb @@ -61,7 +61,7 @@ describe Users::SessionsController, type: :controller do it 'redirects to new_path' do subject - expect(response).to redirect_to(new_user_session_path) + expect(response).to render_template(:new) expect(flash.alert).to eq(I18n.t('devise.failure.invalid')) end end