Last active
August 25, 2019 14:20
-
-
Save rwehresmann/e5bab81212ffe1be9d38b65d1f4ac919 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
| class Auth0Controller < ApplicationController | |
| ... | |
| def failure | |
| end | |
| def logout | |
| if admin_logged_as_another_user? | |
| accessed_user = session[:user_id] | |
| session[:user_id] = session[:admin_user_id] | |
| redirect_to admin_user_path(accessed_user) | |
| else | |
| session.delete(:user_id) | |
| session.delete(:admin_user_id) | |
| redirect_to( | |
| "https://#{ENV.fetch('AUTH0_DOMAIN')}/v2/logout?" + | |
| "client_id=#{ENV.fetch('AUTH0_CLIENT_ID')}&" + | |
| "returnTo=#{URI.encode(root_url)}" | |
| ) | |
| end | |
| end | |
| private | |
| def admin_logged_as_other_user? | |
| session[:user_id] != session[:admin_user_id] | |
| end | |
| ... | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment