Created
April 11, 2012 12:27
-
-
Save JeanMertz/2359034 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def verify_backend_access | |
| # Redirect guest users to login page. | |
| if ! user_signed_in? | |
| redirect_to new_user_session_url(subdomain: subdomain_account.name), notice: 'Not logged in!' | |
| # Redirect users with `Client` roles to signup page. | |
| elsif ! current_user.has_backend_access? | |
| redirect_to new_user_registration_url(subdomain: app_subdomain), notice: 'No access, please sign up!' | |
| # Redirect users without access to this account to their own account page. | |
| elsif request.subdomain == app_subdomain || ! current_user.has_backend_access?(account: subdomain_account) | |
| redirect_to dashboard_url(subdomain: current_account.name), notice: 'Not your account mister!' | |
| end | |
| end | |
| before_filter :verify_backend_access |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| config.to_prepare do | |
| Devise::SessionsController.skip_filter :verify_backend_access | |
| Devise::RegistrationsController.skip_filter :verify_backend_access, only: [:new, :create] | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment