Class: Homeland::ApplicationController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Homeland::ApplicationController
show all
- Defined in:
- app/controllers/homeland/application_controller.rb
Instance Method Summary
collapse
Instance Method Details
#admin? ⇒ Boolean
45
46
47
48
|
# File 'app/controllers/homeland/application_controller.rb', line 45
def admin?
return false if current_user.blank?
current_user.send(Homeland.config.user_admin_method) == true
end
|
#authenticate_user! ⇒ Object
15
16
17
|
# File 'app/controllers/homeland/application_controller.rb', line 15
def authenticate_user!
origin_authenticate_user!
end
|
#authorize_admin! ⇒ Object
25
26
27
28
29
|
# File 'app/controllers/homeland/application_controller.rb', line 25
def authorize_admin!
if !admin?
redirect_to homeland.root_path, alert: t('homeland.access_denied')
end
end
|
#authorize_resource!(obj) ⇒ Object
19
20
21
22
23
|
# File 'app/controllers/homeland/application_controller.rb', line 19
def authorize_resource!(obj)
if !owner?(obj)
redirect_to homeland.root_path, alert: t('homeland.access_denied')
end
end
|
#current_user ⇒ Object
11
12
13
|
# File 'app/controllers/homeland/application_controller.rb', line 11
def current_user
origin_current_user
end
|
#owner?(obj) ⇒ Boolean
37
38
39
40
41
42
43
|
# File 'app/controllers/homeland/application_controller.rb', line 37
def owner?(obj)
return false if obj.blank?
return false if current_user.blank?
return true if current_user.send(Homeland.config.user_admin_method) == true
obj.user_id == current_user.id
end
|
31
32
33
34
35
|
# File 'app/controllers/homeland/application_controller.rb', line 31
def set_seo_meta(title = '', meta_keywords = '', meta_description = '')
@page_title = "#{title}" if title.length > 0
@meta_keywords = meta_keywords
@meta_description = meta_description
end
|