constellation-authorization 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/constellation/authorization/base.rb +36 -8
- metadata +3 -3
@@ -76,16 +76,44 @@ module Constellation
|
|
76
76
|
# Handle redirection within permit if authorization is denied.
|
77
77
|
def handle_redirection
|
78
78
|
return if not self.respond_to?(:redirect_to)
|
79
|
-
|
80
|
-
|
81
|
-
# authentication
|
82
|
-
send(Rails.application.config.constellation.authorization.store_location_method) if respond_to? Rails.application.config.constellation.authorization.store_location_method
|
79
|
+
# Store url in session for return if this is available from authentication
|
80
|
+
send(Rails.application.config.constellation.authorization.store_location_method) if respond_to?(Rails.application.config.constellation.authorization.store_location_method)
|
83
81
|
if @current_user && @current_user != :false
|
84
|
-
|
85
|
-
|
82
|
+
respond_to do |format|
|
83
|
+
format.html do
|
84
|
+
if self.respond_to? :handle_permission_denied_redirection_for_html
|
85
|
+
handle_permission_denied_redirection_for_html
|
86
|
+
else
|
87
|
+
flash[Rails.application.config.constellation.authorization.permission_denied_flash] = @options[:permission_denied_message] || t('constellation.authorization.permission_denied')
|
88
|
+
redirect_to @options[:permission_denied_redirection] || (self.respond_to?(:permission_denied_redirection) ? permission_denied_redirection : Rails.application.config.constellation.authorization.permission_denied_redirection)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
format.all do
|
92
|
+
if self.respond_to? :"handle_permission_denied_redirection_for_#{params[:format]}"
|
93
|
+
self.send :"handle_permission_denied_redirection_for_#{params[:format]}"
|
94
|
+
else
|
95
|
+
render :text => nil, :status => :forbidden
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
86
99
|
else
|
87
|
-
|
88
|
-
|
100
|
+
respond_to do |format|
|
101
|
+
format.html do
|
102
|
+
if self.respond_to? :handle_login_required_redirection_for_html
|
103
|
+
handle_login_required_redirection_for_html
|
104
|
+
else
|
105
|
+
flash[Rails.application.config.constellation.authorization.login_required_flash] = @options[:login_required_message] || t('constellation.authorization.login_required')
|
106
|
+
redirect_to @options[:login_required_redirection] || (self.respond_to?(:login_required_redirection) ? login_required_redirection : Rails.application.config.constellation.authorization.login_required_redirection)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
format.all do
|
110
|
+
if self.respond_to? :"handle_login_required_redirection_for_#{params[:format]}"
|
111
|
+
self.send :"handle_login_required_redirection_for_#{params[:format]}"
|
112
|
+
else
|
113
|
+
render :text => nil, :status => :unauthorized
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
89
117
|
end
|
90
118
|
false # Want to short-circuit the filters
|
91
119
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 2.0.
|
8
|
+
- 4
|
9
|
+
version: 2.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Bill Katz
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-05-
|
19
|
+
date: 2010-05-06 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|