caboose-cms 0.8.15 → 0.8.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa3fb1432258306db56b298525446cec698aef03
4
- data.tar.gz: af42acc488025424bde48a48764fb0f26f429289
3
+ metadata.gz: b694873b2acdf08025a9ff83ce34d097e00c0c87
4
+ data.tar.gz: 607782e94412ee709653e88b2ad9662e11592f17
5
5
  SHA512:
6
- metadata.gz: 7de9d53efb3a7144a5cca592a972d866f0b67c1654f650b98a37021b80108c3cf8bd6ee92736f25e42dd450d74b17162b6d82850ee51b7a88dc81308107a8f14
7
- data.tar.gz: d54163fb97e4ad21788e95524576e7ae6882fada323db3090740b9105b59a0c9d98fa694efe1c3e77b3eb05e99e15cbf510432d22d5d5558ead87bc5bc51f654
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 (!logged_in?)
192
- redirect_to "/login?return_url=" + URI.encode(request.fullpath)
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 (!@user.is_allowed(resource, action))
198
- @error = "You don't have permission to " + action + " " + resource
199
- @return_url = request.fullpath
200
- render :template => "caboose/extras/error"
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
- redirect_to "/login?return_url=" + URI.encode(request.fullpath)
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
- @error = "You don't have permission to #{action} #{resource}"
225
- @return_url = request.fullpath
226
- render :template => "caboose/extras/error"
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 => pag_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
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.8.15'
2
+ VERSION = '0.8.16'
3
3
  end
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.15
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-01 00:00:00.000000000 Z
11
+ date: 2016-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg