refactor: user management

This commit is contained in:
Adam Cooke
2021-07-28 14:17:59 +00:00
parent e9a52e9512
commit daf469ce7f
27 changed files with 106 additions and 359 deletions
+1 -14
View File
@@ -5,7 +5,6 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :login_required
before_action :verified_email_required
before_action :set_timezone
rescue_from Authie::Session::InactiveSession, :with => :auth_session_error
@@ -23,25 +22,13 @@ class ApplicationController < ActionController::Base
def admin_required
if logged_in?
unless current_user.admin?
render :text => "Not permitted"
render :plain => "Not permitted"
end
else
redirect_to login_path(:return_to => request.fullpath)
end
end
def verified_email_required
if logged_in? && !current_user.verified?
redirect_to verify_path(:return_to => request.fullpath)
end
end
def require_organization_admin
unless organization.admin?(current_user)
redirect_to organization_root_path(organization), :alert => "This page can only be accessed by the organization admins"
end
end
def require_organization_owner
unless organization.owner == current_user
redirect_to organization_root_path(organization), :alert => "This page can only be accessed by the organization's owner (#{organization.owner.name})"