the_role_api 3.0.3 → 3.5

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: 6e674f0dd2dc0594d5ac45772e90d9598e3826f9
4
- data.tar.gz: a09b705f2a54564c4ace010b930d4dc44352b7f8
3
+ metadata.gz: 5a844d9bf293e91485ac8d799c3290c7d0bb2632
4
+ data.tar.gz: 089fa53faea125dfea6ffe8beb4d6643cb57c09b
5
5
  SHA512:
6
- metadata.gz: 792835ea786a1213b135f3474df426b56298c65105a4f0415e7f9dc809e050aa6e974cda0eaa501c49243f95ba5b59d4ae9696596c445de907fb714dee13a1bd
7
- data.tar.gz: e77808eb708ba630b59eda57dbde30c4af27ee624b1f25f70a018d6ee7d7706166f688d1578ed86267c4c3cfe04b00c3b89330db0e5865e95ab3eb51020e88f9
6
+ metadata.gz: 5d3d457ce0c1978db76cc1d7204a7ba65e148d1f6ee896da9a0f1209a4addb94fd98826f9685d88b70c4721a6b8f5afbb9785f8f1ef959e3c9ce5c33669c3035
7
+ data.tar.gz: 54d290cd963068817beedc68097786cbaca2fc2d0509655425dfe75bd682be3077ff20b9389a3cb1db2e5887ef21d71cac4cebfe3a08cdc56140192c253adee4
data/README.md CHANGED
@@ -16,14 +16,11 @@
16
16
  </p>
17
17
 
18
18
  <div align="center" class='center' style="text-align:center">
19
-
20
- <a href="http://badge.fury.io/rb/the_role"><img src="https://badge.fury.io/rb/the_role.svg" alt="Gem Version" height="18"></a>
21
- &nbsp;
22
- <a href="https://travis-ci.org/TheRole/DummyApp"><img src="https://travis-ci.org/TheRole/DummyApp.svg?branch=master" alt="Build Status" height="18"></a>
23
- &nbsp;
24
- <a href="https://codeclimate.com/github/TheRole/TheRoleApi"><img src="https://codeclimate.com/github/TheRole/TheRoleApi/badges/gpa.svg" /></a>
25
- &nbsp;
26
- <a href="https://www.ruby-toolbox.com/categories/rails_authorization">ruby-toolbox</a>
19
+ TheRole: <a href="http://badge.fury.io/rb/the_role"><img src="https://badge.fury.io/rb/the_role.svg" alt="Gem Version" height="18"></a>
20
+ API: <a href="http://badge.fury.io/rb/the_role_api"><img src="https://badge.fury.io/rb/the_role_api.svg" alt="Gem Version" height="18"></a>
21
+ GUI: <a href="http://badge.fury.io/rb/the_role_management_panel"><img src="https://badge.fury.io/rb/the_role_management_panel.svg" alt="Gem Version" height="18"></a>
22
+ CI: <a href="https://travis-ci.org/TheRole/DummyApp"><img src="https://travis-ci.org/TheRole/DummyApp.svg?branch=master" alt="Build Status" height="18"></a>
23
+ &nbsp;<a href="https://www.ruby-toolbox.com/categories/rails_authorization">ruby-toolbox</a>
27
24
  </div>
28
25
 
29
26
  <hr>
@@ -46,7 +46,12 @@ module TheRole
46
46
  has_access_to_object: current_user.try(:owner?, @owner_check_object)
47
47
  }, status: 401
48
48
  else
49
- redirect_to :back, flash: { error: access_denied_msg }
49
+ # When the user paste non authorized URL in browser the REFERER is blank and application crash
50
+ if request.env["HTTP_REFERER"].present? and request.env["HTTP_REFERER"] != request.env["REQUEST_URI"]
51
+ redirect_to :back, flash: { error: access_denied_msg }
52
+ else
53
+ redirect_to root_path, flash: { error: access_denied_msg }
54
+ end
50
55
  end
51
56
  end
52
57
  end
@@ -27,6 +27,7 @@ module TheRole
27
27
  def to_json
28
28
  the_role
29
29
  end
30
+
30
31
  # ~ HELPERS
31
32
 
32
33
  alias_method :has?, :has_role?
@@ -55,7 +56,7 @@ module TheRole
55
56
  end
56
57
 
57
58
  after_create do
58
- unless based_on_role.blank?
59
+ if based_on_role.present?
59
60
  if base_role = self.class.where(id: based_on_role).first
60
61
  update_role base_role.to_hash
61
62
  end
@@ -6,11 +6,14 @@ module TheRole
6
6
  include TheRole::Api::BaseMethods
7
7
 
8
8
  # HELPERS
9
+
9
10
  # version for `User` model
10
11
  def role_hash
11
12
  @role_hash ||= role.try(:to_hash) || {}
12
13
  end
13
14
 
15
+ # ~ HELPERS
16
+
14
17
  included do
15
18
  belongs_to :role
16
19
  before_validation :set_default_role, on: :create
@@ -1,3 +1,12 @@
1
1
  zh_CN:
2
+ activerecord:
3
+ models:
4
+ role: "角色"
5
+ attributes:
6
+ role:
7
+ name: "角色名"
8
+ title: "角色代码"
9
+ description: "角色描述"
10
+
2
11
  the_role:
3
- access_denied: "Access Denied"
12
+ access_denied: "拒绝访问"
data/gem_version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TheRoleApi
2
- VERSION = "3.0.3"
2
+ VERSION = "3.5"
3
3
  end
data/lib/the_role_api.rb CHANGED
@@ -30,17 +30,11 @@ module TheRole
30
30
  %w[ base_methods role user ].each do |file|
31
31
  require_dependency "#{ app }/models/concerns/the_role/api/#{ file }.rb"
32
32
  end
33
- end
34
-
35
- if Rails::VERSION::MAJOR == 4
33
+ else
36
34
  config.autoload_paths << "#{ config.root }/app/models/concerns/**"
37
35
  config.autoload_paths << "#{ config.root }/app/controllers/concerns/**"
38
36
  end
39
37
 
40
- if Rails::VERSION::MAJOR == 5
41
- raise Exception.new("TheRole 3. Version for Rails 5 not tested yet")
42
- end
43
-
44
38
  initializer "the_role_precompile_hook", group: :all do |app|
45
39
  app.config.assets.precompile += %w(
46
40
  the_role_management_panel.js
data/the_role_api.gemspec CHANGED
@@ -19,5 +19,5 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.add_dependency 'multi_json'
21
21
  s.add_dependency 'the_string_to_slug', '~> 1.2'
22
- s.add_runtime_dependency 'rails', ['>= 3.2', '< 5']
22
+ s.add_runtime_dependency 'rails', ['>= 3.2', '< 6']
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the_role_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: '3.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya N. Zykin [the-teacher]
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2016-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: '3.2'
48
48
  - - "<"
49
49
  - !ruby/object:Gem::Version
50
- version: '5'
50
+ version: '6'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: '3.2'
58
58
  - - "<"
59
59
  - !ruby/object:Gem::Version
60
- version: '5'
60
+ version: '6'
61
61
  description: Authorization for Rails with Web Interface
62
62
  email:
63
63
  - zykin-ilya@ya.ru
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  version: '0'
116
116
  requirements: []
117
117
  rubyforge_project:
118
- rubygems_version: 2.2.2
118
+ rubygems_version: 2.5.0
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: Authorization for Rails