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
|
||||
|
|
|
@ -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