2015-12-09 15:10:11 +01:00
|
|
|
class Users::SessionsController < Sessions::SessionsController
|
2015-09-23 10:02:01 +02:00
|
|
|
# before_filter :configure_sign_in_params, only: [:create]
|
|
|
|
|
2016-02-15 17:13:16 +01:00
|
|
|
def demo
|
2016-02-19 15:04:29 +01:00
|
|
|
return redirect_to root_path if Rails.env.production?
|
|
|
|
|
2016-02-15 17:13:16 +01:00
|
|
|
@user = User.new(email: 'demo@tps.fr', password: 'password')
|
|
|
|
|
|
|
|
render 'new'
|
|
|
|
end
|
|
|
|
|
2015-12-24 10:12:23 +01:00
|
|
|
# GET /resource/sign_in
|
2016-02-15 17:13:16 +01:00
|
|
|
def new
|
|
|
|
@user = User.new
|
|
|
|
end
|
2015-09-23 10:02:01 +02:00
|
|
|
|
2015-12-24 10:12:23 +01:00
|
|
|
#POST /resource/sign_in
|
2015-10-07 14:19:16 +02:00
|
|
|
def create
|
|
|
|
super
|
|
|
|
|
2015-12-24 10:12:23 +01:00
|
|
|
current_user.update_attributes(loged_in_with_france_connect: '')
|
2015-10-07 14:19:16 +02:00
|
|
|
end
|
2015-09-23 10:02:01 +02:00
|
|
|
|
2016-02-15 17:13:16 +01:00
|
|
|
# DELETE /resource/sign_out
|
2015-10-07 16:38:29 +02:00
|
|
|
def destroy
|
2015-10-08 11:26:12 +02:00
|
|
|
connected_with_france_connect = current_user.loged_in_with_france_connect
|
2015-12-24 10:12:23 +01:00
|
|
|
current_user.update_attributes(loged_in_with_france_connect: '')
|
2015-10-07 16:38:29 +02:00
|
|
|
|
|
|
|
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
|
|
|
|
set_flash_message :notice, :signed_out if signed_out && is_flashing_format?
|
|
|
|
yield if block_given?
|
|
|
|
|
2015-12-24 10:12:23 +01:00
|
|
|
if connected_with_france_connect == 'entreprise'
|
2015-12-18 12:01:26 +01:00
|
|
|
redirect_to FRANCE_CONNECT.entreprise_logout_endpoint
|
2015-12-24 10:12:23 +01:00
|
|
|
elsif connected_with_france_connect == 'particulier'
|
|
|
|
redirect_to FRANCE_CONNECT.particulier_logout_endpoint
|
2015-10-07 16:38:29 +02:00
|
|
|
else
|
|
|
|
respond_to_on_destroy
|
|
|
|
end
|
|
|
|
end
|
2015-09-23 10:02:01 +02:00
|
|
|
|
2015-12-24 10:12:23 +01:00
|
|
|
# protected
|
2015-09-23 10:02:01 +02:00
|
|
|
|
2015-12-24 10:12:23 +01:00
|
|
|
# You can put the params you want to permit in the empty array.
|
|
|
|
# def configure_sign_in_params
|
|
|
|
# devise_parameter_sanitizer.for(:sign_in) << :attribute
|
|
|
|
# end
|
2015-09-23 10:02:01 +02:00
|
|
|
end
|