diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 5f36bfa2..95f096d6 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -12,6 +12,7 @@ en: unconfirmed: 'You have to confirm your account before continuing.' locked: 'Your account is locked.' invalid: 'Invalid email or password.' + no_membership: 'Your account is not a member of this site, please contact the site administrator to gain access.' invalid_token: 'Invalid authentication token.' timeout: 'Your session expired, please sign in again to continue.' inactive: 'Your account was not activated yet.' diff --git a/lib/locomotive/routing/site_dispatcher.rb b/lib/locomotive/routing/site_dispatcher.rb index 1678d3b3..c1e66ed2 100644 --- a/lib/locomotive/routing/site_dispatcher.rb +++ b/lib/locomotive/routing/site_dispatcher.rb @@ -38,8 +38,11 @@ module Locomotive end def validate_site_membership - return if current_site && current_site.accounts.include?(current_admin) - sign_out_and_redirect(current_admin) + unless current_site.present? && current_site.accounts.include?(current_admin) + sign_out(current_admin) + flash[:alert] = I18n.t(:no_membership, :scope => [:devise, :failure, :admin]) + redirect_to new_admin_session_url + end end end