change masquerade permissions

This commit is contained in:
Andrew Brown 2018-10-31 13:19:13 -05:00
parent f0b6619e1b
commit f6c1b7817f
2 changed files with 6 additions and 5 deletions

View File

@ -2,7 +2,7 @@ class AdminController < ApplicationController
layout 'admin'
before_action :authenticate_user!
before_action :require_admin_access, except: [:masquerade]
before_action :require_admin_access
def dashboard
end
@ -32,14 +32,15 @@ class AdminController < ApplicationController
end
def masquerade
# Do not allow masquerading in production, even for admins.
return unless Rails.env.development?
masqueree = User.find_by(id: params[:user_id])
sign_in masqueree
redirect_to root_path
end
def unsubscribe
end
private
def require_admin_access

View File

@ -166,11 +166,11 @@ Rails.application.routes.draw do
scope 'admin_stats' do
get '/', to: 'admin#dashboard', as: :admin_dashboard
get '/content_type/:type', to: 'admin#content_type', as: :admin_content_type
get '/attributes', to: 'admin#attributes', as: :admin_attributes
get '/masquerade/:user_id', to: 'admin#masquerade', as: :masquerade
end
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
get '/admin/unsubscribe', to: 'admin#unsubscribe'
scope 'export' do
get '/', to: 'export#index', as: :notebook_export