Remove weird switch_devise_profile_service
This commit is contained in:
parent
754f10e4b2
commit
e3fd1cc33a
5 changed files with 11 additions and 27 deletions
|
@ -44,6 +44,14 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
helper_method :logged_in?
|
helper_method :logged_in?
|
||||||
|
|
||||||
|
def multiple_devise_profile_connect?
|
||||||
|
user_signed_in? && instructeur_signed_in? ||
|
||||||
|
instructeur_signed_in? && administrateur_signed_in? ||
|
||||||
|
user_signed_in? && administrateur_signed_in?
|
||||||
|
end
|
||||||
|
|
||||||
|
helper_method :multiple_devise_profile_connect?
|
||||||
|
|
||||||
def pundit_user
|
def pundit_user
|
||||||
{
|
{
|
||||||
administrateur: current_administrateur,
|
administrateur: current_administrateur,
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
class SwitchDeviseProfileService
|
|
||||||
def initialize(warden)
|
|
||||||
@warden = warden
|
|
||||||
end
|
|
||||||
|
|
||||||
def multiple_devise_profile_connect?
|
|
||||||
user_signed_in? && instructeur_signed_in? ||
|
|
||||||
instructeur_signed_in? && administrateur_signed_in? ||
|
|
||||||
user_signed_in? && administrateur_signed_in?
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def user_signed_in?
|
|
||||||
@warden.authenticate(:scope => :user).present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def instructeur_signed_in?
|
|
||||||
@warden.authenticate(:scope => :instructeur).present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def administrateur_signed_in?
|
|
||||||
@warden.authenticate(:scope => :administrateur).present?
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -10,7 +10,7 @@
|
||||||
= link_to manager_root_path, class: "menu-item menu-link" do
|
= link_to manager_root_path, class: "menu-item menu-link" do
|
||||||
= image_tag "icons/super-admin.svg"
|
= image_tag "icons/super-admin.svg"
|
||||||
Passer en super-admin
|
Passer en super-admin
|
||||||
- if SwitchDeviseProfileService.new(warden).multiple_devise_profile_connect?
|
- if multiple_devise_profile_connect?
|
||||||
- if user_signed_in? && nav_bar_profile != :user
|
- if user_signed_in? && nav_bar_profile != :user
|
||||||
%li
|
%li
|
||||||
= link_to dossiers_path, class: "menu-item menu-link" do
|
= link_to dossiers_path, class: "menu-item menu-link" do
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
- if SwitchDeviseProfileService.new(warden).multiple_devise_profile_connect?
|
- if multiple_devise_profile_connect?
|
||||||
%ul#switch-menu
|
%ul#switch-menu
|
||||||
%li
|
%li
|
||||||
Changer de rôle
|
Changer de rôle
|
||||||
|
|
|
@ -2,6 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe 'layouts/_new_header.html.haml', type: :view do
|
describe 'layouts/_new_header.html.haml', type: :view do
|
||||||
before do
|
before do
|
||||||
|
allow(view).to receive(:multiple_devise_profile_connect?).and_return(false)
|
||||||
if user
|
if user
|
||||||
sign_in user
|
sign_in user
|
||||||
allow(controller).to receive(:nav_bar_profile).and_return(profile)
|
allow(controller).to receive(:nav_bar_profile).and_return(profile)
|
||||||
|
|
Loading…
Add table
Reference in a new issue