add login for gestionnaire

This commit is contained in:
Tanguy PATTE 2015-09-22 10:15:12 +02:00
parent b3383bec9f
commit 44173a17fb
26 changed files with 313 additions and 142 deletions

View file

@ -1,5 +1,5 @@
class Admin::DossierController < ApplicationController
before_action :authenticate_user!
before_action :authenticate_gestionnaire!
def show
@dossier = Dossier.find(params[:dossier_id])
@ -8,7 +8,7 @@ class Admin::DossierController < ApplicationController
@pieces_justificatives = @dossier.pieces_justificatives
@commentaires = @dossier.commentaires.order(created_at: :desc)
@commentaires = @commentaires.all.decorate
@commentaire_email = current_user.email
@commentaire_email = current_gestionnaire.email
@procedure = @dossier.procedure

View file

@ -3,20 +3,21 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_action :store_location
# before_action :store_location
def store_location
unless params[:controller] == 'devise/sessions'
url = "/admin/dossiers/#{params[:dossier_id]}"
session[:user_return_to] = url
end
end
# def store_location
# unless params[:controller] == 'devise/sessions'
# url = "/admin/dossiers/#{params[:dossier_id]}"
# session[:user_return_to] = url
# end
# end
def stored_location_for(resource_or_scope)
session[:user_return_to] || super
end
# def stored_location_for(resource_or_scope)
# session[:user_return_to] || super
# end
def after_sign_in_path_for(resource)
stored_location_for(resource) || root_path
end
# def after_sign_in_path_for(resource)
# puts "========================= coucou #{resource}"
# stored_location_for(resource) || root_path
# end
end

View file

@ -0,0 +1,7 @@
class BackofficeController < ApplicationController
def index
redirect_to(controller: '/gestionnaires/sessions', action: :new) unless gestionnaire_signed_in?
end
end

View file

@ -0,0 +1,16 @@
class Gestionnaires::SessionsController < Devise::SessionsController
def new
@gestionnaire = Gestionnaire.new
end
def create
super
end
def after_sign_in_path_for(resource)
# stored_location_for(resource) ||
backoffice_path
end
end

View file

@ -1,25 +0,0 @@
class Pros::SessionsController < Devise::SessionsController
# before_filter :configure_sign_in_params, only: [:create]
# GET /resource/sign_in
def new
super
end
# POST /resource/sign_in
def create
super
end
# DELETE /resource/sign_out
# def destroy
# super
# end
# protected
# 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
end

View file

@ -1,14 +1,3 @@
class User::CustomFailure < Devise::FailureApp
def redirect_url
url_for(controller: '/start', action: :index)
end
# You need to override respond to eliminate recall
def respond
if http_auth?
http_auth
else
redirect
end
end
end

View file

@ -1,25 +1,3 @@
class User::SessionsController < Devise::SessionsController
# before_filter :configure_sign_in_params, only: [:create]
# GET /resource/sign_in
def new
redirect_to url_for(controller: '/start', action: :error_login)
end
# POST /resource/sign_in
def create
super
end
# DELETE /resource/sign_out
def destroy
super
end
# protected
# 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
end