add profiles in flash after sign-in if multiple profile
This commit is contained in:
parent
dfc09648d8
commit
0286d2b6fb
5 changed files with 24 additions and 1 deletions
|
@ -16,6 +16,9 @@ class Users::SessionsController < Devise::SessionsController
|
|||
end
|
||||
|
||||
super
|
||||
if current_account.count > 1
|
||||
flash[:notice] = t("devise.sessions.signed_in_multiple_profile", roles: current_account.keys.map { |role| t("layouts.#{role}") }.join(', '))
|
||||
end
|
||||
end
|
||||
|
||||
def reset_link_sent
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
%nav.fr-translate.fr-nav{ role: "navigation", "aria-label"=> t('menu_aria_label', scope: [:layouts]) }
|
||||
.fr-nav__item
|
||||
%button.account-btn.fr-translate__btn.fr-btn{ "aria-controls" => "account", "aria-expanded" => "false", :title => t('my_account', scope: [:layouts]) }
|
||||
%div{ class: "fr-badge fr-badge--sm fr-mr-1w #{color_by_role(nav_bar_profile)}"}
|
||||
%div{ class: "fr-badge fr-badge--sm fr-mr-1w #{color_by_role(nav_bar_profile)}" }
|
||||
= t("layouts.#{nav_bar_profile}")
|
||||
= " #{current_email}"
|
||||
#account.fr-collapse.fr-menu
|
||||
|
|
|
@ -3,3 +3,5 @@ en:
|
|||
passwords:
|
||||
new:
|
||||
request_new_password: Request new password
|
||||
sessions:
|
||||
signed_in_multiple_profile: "You are connected ! You can switch between your multiple profiles : %{roles}."
|
||||
|
|
|
@ -3,3 +3,5 @@ fr:
|
|||
passwords:
|
||||
new:
|
||||
request_new_password: Demander un nouveau mot de passe
|
||||
sessions:
|
||||
signed_in_multiple_profile: "Vous êtes connecté(e) ! Vous pouvez à tout moment alterner entre vos différents profils : %{roles}."
|
||||
|
|
|
@ -12,6 +12,22 @@ describe 'Signin in:' do
|
|||
|
||||
sign_in_with user.email, password
|
||||
expect(page).to have_current_path dossiers_path
|
||||
expect(page).to have_content('Connecté(e).')
|
||||
expect(page).not_to have_content('Vous pouvez à tout moment alterner')
|
||||
end
|
||||
|
||||
context 'user has multiple profiles' do
|
||||
let!(:instructeur) { create(:instructeur, user: user) }
|
||||
let!(:admin) { create(:administrateur, user: user, instructeur: instructeur) }
|
||||
|
||||
scenario 'he can sign-in and he is notified in flash' do
|
||||
visit root_path
|
||||
click_on 'Se connecter', match: :first
|
||||
|
||||
sign_in_with user.email, password
|
||||
expect(page).to have_current_path admin_procedures_path
|
||||
expect(page).to have_content('Vous êtes connecté(e) ! Vous pouvez à tout moment alterner entre vos différents profils : administrateur, instructeur, usager.')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'an existing user can lock its account' do
|
||||
|
|
Loading…
Reference in a new issue