caboose-cms 0.8.15 → 0.8.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b694873b2acdf08025a9ff83ce34d097e00c0c87
|
4
|
+
data.tar.gz: 607782e94412ee709653e88b2ad9662e11592f17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 350418a458a5c6542bb59aa9bdbbdca4d9c0e2613199d9bf3f2b1bf2f77ea4171ee128bd35987744a4aac90d38fd4ac8d7808f17bed01e1a748f81a71a69b9d4
|
7
|
+
data.tar.gz: 59b14e3cf1cba296916232aa48db9e9406a00050cc4169f15134c8fe2ee18820de6670a55c415c0f7ea9e95189f2114fbfc562415f0e4129242c5866a9167eb1
|
@@ -187,17 +187,25 @@ module Caboose
|
|
187
187
|
# on the given resource.
|
188
188
|
# Redirects to login if not logged in.
|
189
189
|
# Redirects to error page with message if not allowed.
|
190
|
-
def user_is_allowed(resource, action)
|
191
|
-
if
|
192
|
-
|
190
|
+
def user_is_allowed(resource, action, json = false)
|
191
|
+
if !logged_in?
|
192
|
+
if json
|
193
|
+
render :json => false
|
194
|
+
else
|
195
|
+
redirect_to "/login?return_url=" + URI.encode(request.fullpath)
|
196
|
+
end
|
193
197
|
return false
|
194
198
|
end
|
195
199
|
|
196
200
|
@user = logged_in_user
|
197
|
-
if
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
+
if !@user.is_allowed(resource, action)
|
202
|
+
if json
|
203
|
+
render :json => false
|
204
|
+
else
|
205
|
+
@error = "You don't have permission to " + action + " " + resource
|
206
|
+
@return_url = request.fullpath
|
207
|
+
render :template => "caboose/extras/error"
|
208
|
+
end
|
201
209
|
return false
|
202
210
|
end
|
203
211
|
|
@@ -213,17 +221,25 @@ module Caboose
|
|
213
221
|
# useful for creating super-readable code, for example:
|
214
222
|
# > return unless user_is_allowed_to 'edit', 'pages'
|
215
223
|
# Even your mom could read that code.
|
216
|
-
def user_is_allowed_to(action, resource)
|
224
|
+
def user_is_allowed_to(action, resource, json = false)
|
217
225
|
unless logged_in?
|
218
|
-
|
226
|
+
if json
|
227
|
+
render :json => { :error => 'Not logged in.' }
|
228
|
+
else
|
229
|
+
redirect_to "/login?return_url=" + URI.encode(request.fullpath)
|
230
|
+
end
|
219
231
|
return false
|
220
232
|
end
|
221
233
|
|
222
234
|
@user = logged_in_user
|
223
235
|
unless @user.is_allowed(resource, action)
|
224
|
-
|
225
|
-
|
226
|
-
|
236
|
+
if json
|
237
|
+
render :json => { :error => "You don't have permission." }
|
238
|
+
else
|
239
|
+
@error = "You don't have permission to #{action} #{resource}"
|
240
|
+
@return_url = request.fullpath
|
241
|
+
render :template => "caboose/extras/error"
|
242
|
+
end
|
227
243
|
return false
|
228
244
|
end
|
229
245
|
return true
|
@@ -14,7 +14,7 @@ class Caboose::PageCustomFieldValue < ActiveRecord::Base
|
|
14
14
|
def duplicate(page_id, page_custom_field_id)
|
15
15
|
v = Caboose::PageCustomFieldValue.create(
|
16
16
|
:page_id => page_id,
|
17
|
-
:page_custom_field_id =>
|
17
|
+
:page_custom_field_id => page_custom_field_id,
|
18
18
|
:key => self.key,
|
19
19
|
:value => self.value,
|
20
20
|
:sort_order => self.sort_order
|
data/lib/caboose/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|