Class: AuthorityController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/authority_controller.rb

Instance Method Summary collapse

Instance Method Details

#ensure_accessible!Object



23
24
25
26
27
28
29
30
# File 'app/controllers/authority_controller.rb', line 23

def ensure_accessible!
  if controller_name != "sessions"
    accessible_user_role = Role.find_by_name(ACCESSIBLE_ROLE_NAME)
    if !current_user.roles.include? accessible_user_role
      raise 'Unauthorized Action'
    end
  end
end

#ensure_admin!Object



14
15
16
17
18
19
20
21
# File 'app/controllers/authority_controller.rb', line 14

def ensure_admin!
  if controller_name != "sessions"
    admin_user_role = Role.find_by_name(ADMIN_ROLE_NAME)
    if !current_user.roles.include? admin_user_role
      raise 'Unauthorized Action'
    end
  end
end

#ensure_super_admin!Object



5
6
7
8
9
10
11
12
# File 'app/controllers/authority_controller.rb', line 5

def ensure_super_admin!
  if controller_name != "sessions"
    super_user_role = Role.find(1)
    if !current_user.roles.include? super_user_role
      raise 'Unauthorized Action'
    end  
  end
end