Merge branch 'develop' into staging

This commit is contained in:
Simon Lehericey 2017-03-07 14:33:14 +01:00
commit 2b04bf1dfd
3 changed files with 18 additions and 25 deletions

View file

@ -10,7 +10,7 @@ class Users::SessionsController < Sessions::SessionsController
# GET /resource/sign_in # GET /resource/sign_in
def new def new
unless user_return_to_procedure_id.nil? unless user_return_to_procedure_id.nil? # WTF ?
@dossier = Dossier.new(procedure: Procedure.active(user_return_to_procedure_id)) @dossier = Dossier.new(procedure: Procedure.active(user_return_to_procedure_id))
end end
@ -21,9 +21,10 @@ class Users::SessionsController < Sessions::SessionsController
#POST /resource/sign_in #POST /resource/sign_in
def create def create
try_to_authenticate(User) remember_me = params[:user][:remember_me] == '1'
try_to_authenticate(Gestionnaire) try_to_authenticate(User, remember_me)
try_to_authenticate(Administrateur) try_to_authenticate(Gestionnaire, remember_me)
try_to_authenticate(Administrateur, remember_me)
if user_signed_in? if user_signed_in?
current_user.update_attributes(loged_in_with_france_connect: '') current_user.update_attributes(loged_in_with_france_connect: '')
@ -83,9 +84,10 @@ class Users::SessionsController < Sessions::SessionsController
NumberService.to_number session["user_return_to"].split("?procedure_id=").second NumberService.to_number session["user_return_to"].split("?procedure_id=").second
end end
def try_to_authenticate(klass) def try_to_authenticate(klass, remember_me = false)
if resource = klass.find_for_database_authentication(email: params[:user][:email]) if resource = klass.find_for_database_authentication(email: params[:user][:email])
if resource.valid_password?(params[:user][:password]) if resource.valid_password?(params[:user][:password])
resource.remember_me = remember_me
sign_in resource sign_in resource
resource.force_sync_credentials resource.force_sync_credentials
set_flash_message :notice, :signed_in set_flash_message :notice, :signed_in

View file

@ -13,25 +13,16 @@
Quest-ce que FranceConnect ? Quest-ce que FranceConnect ?
%hr %hr
= form_for @user, url: user_session_path, method: :post do |f|
%h4 .text-left
= f.label :email = simple_form_for @user, url: user_session_path do |f|
.input-group = f.input :email
.input-group-addon = f.input :password, label: 'Mot de passe', input_html: { value: @user.password }
%span.fa.fa-user - if devise_mapping.rememberable?
= f.email_field :email, class: 'form-control' = f.input :remember_me, as: :boolean, label: 'Se souvenir de moi'
%br .text-center
%h4 = f.submit "Se connecter", class:'btn btn-primary'
= f.label 'Mot de passe'
.input-group
.input-group-addon
%span.fa.fa-asterisk
= f.password_field :password, class: 'form-control', value: "#{@user.password}"
%br
%br
.actions
= f.submit "Se connecter", class:'btn btn-primary'
%br
- if @user.email != DemoEmails[:gestionnaire] && @user.email != DemoEmails[:admin] - if @user.email != DemoEmails[:gestionnaire] && @user.email != DemoEmails[:admin]
= render "users/shared/links" = render "users/shared/links"

View file

@ -126,7 +126,7 @@ Devise.setup do |config|
# ==> Configuration for :rememberable # ==> Configuration for :rememberable
# The time the user will be remembered without asking for credentials again. # The time the user will be remembered without asking for credentials again.
# config.remember_for = 2.weeks config.remember_for = 2.weeks
# Invalidates all the remember me tokens when the user signs out. # Invalidates all the remember me tokens when the user signs out.
config.expire_all_remember_me_on_sign_out = true config.expire_all_remember_me_on_sign_out = true