petergate 1.8.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +1 -1
- data/Gemfile +5 -7
- data/README.md +1 -2
- data/lib/petergate/action_controller/base.rb +16 -7
- data/lib/petergate/version.rb +1 -1
- data/petergate.gemspec +2 -2
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b89a0c9300610e05daeef353a8ac93f1b6507fc08217d821fffe763eab01d438
|
4
|
+
data.tar.gz: ed4b17af73fd19a1d23ab2618b9c4c2704fe01bcd1f1a3f1ac4e79fd6a31bf42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d98025f72708b72fa33acb530adb39402c58248e6cdbdda544fe289d0c70f3bfdd746f129a97d267969ce15697d105cb5fa445f58016dc1a3441ce65a8143cfe
|
7
|
+
data.tar.gz: 004f27cd0ff637921b2b4167f522497e4fbcd5b7b2147a797efa82fff6e68ff4785f15d4b3dc01a8cc24f59dbb572f4a7f3b8176b9d2732993380cf8fcb1c032
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.1
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
ruby '
|
2
|
+
ruby '3.0.1'
|
3
3
|
|
4
4
|
# Specify your gem's dependencies in petergate.gemspec
|
5
5
|
gemspec
|
6
6
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
7
|
-
gem 'rails', '
|
7
|
+
gem 'rails', '~> 6.0.3.4'
|
8
|
+
|
8
9
|
# Use sqlite3 as the database for Active Record
|
9
10
|
gem 'sqlite3'
|
10
11
|
# Use SCSS for stylesheets
|
11
|
-
gem 'sass-rails', '~>
|
12
|
+
gem 'sass-rails', '~> 5.0.4'
|
12
13
|
# Use Uglifier as compressor for JavaScript assets
|
13
14
|
gem 'uglifier', '>= 1.3.0'
|
14
|
-
# Use CoffeeScript for .js.coffee assets and views
|
15
|
-
gem 'coffee-rails', '~> 4.0.0'
|
16
15
|
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
17
16
|
# gem 'therubyracer', platforms: :ruby
|
18
17
|
|
@@ -20,7 +19,7 @@ gem 'coffee-rails', '~> 4.0.0'
|
|
20
19
|
gem 'jquery-rails'
|
21
20
|
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
22
21
|
gem 'turbolinks'
|
23
|
-
gem "minitest-rails"
|
22
|
+
gem "minitest-rails", "~> 6.0.1"
|
24
23
|
gem "minitest-reporters"
|
25
24
|
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
26
25
|
gem 'jbuilder', '~> 2.0'
|
@@ -28,7 +27,6 @@ gem 'jbuilder', '~> 2.0'
|
|
28
27
|
gem 'sdoc', '~> 0.4.0', group: :doc
|
29
28
|
|
30
29
|
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
31
|
-
gem 'spring', group: :development
|
32
30
|
gem 'devise'
|
33
31
|
|
34
32
|
# Use ActiveModel has_secure_password
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
[![Petergate](https://github.com/elorest/petergate/blob/master/dummy/public/petergate.png)](https://github.com/elorest/petergate)
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/elorest/petergate.svg)](https://travis-ci.org/
|
3
|
+
[![Build Status](https://travis-ci.org/elorest/petergate.svg)](https://travis-ci.org/dburnsii/petergate)
|
4
4
|
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/isaacsloan/petergate?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/petergate.svg)](http://badge.fury.io/rb/petergate)
|
6
6
|
|
@@ -33,7 +33,6 @@ and called User.
|
|
33
33
|
|
34
34
|
If you're using [devise](https://github.com/plataformatec/devise) you're in luck, otherwise you'll have to add following methods to your project:
|
35
35
|
|
36
|
-
user_signed_in?
|
37
36
|
current_user
|
38
37
|
after_sign_in_path_for(current_user)
|
39
38
|
authenticate_user!
|
@@ -38,6 +38,7 @@ module Petergate
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def inherited(subclass)
|
41
|
+
super
|
41
42
|
subclass.instance_variable_set("@_controller_rules", instance_variable_get("@_controller_rules"))
|
42
43
|
subclass.instance_variable_set("@_controller_message", instance_variable_get("@_controller_message"))
|
43
44
|
end
|
@@ -80,7 +81,7 @@ module Petergate
|
|
80
81
|
|
81
82
|
h.merge({k => special_values})
|
82
83
|
end
|
83
|
-
# Allows Array's of keys for
|
84
|
+
# Allows Array's of keys for the same hash.
|
84
85
|
rules = rules.inject({}){|h, (k, v)| k.class == Array ? h.merge(Hash[k.map{|kk| [kk, v]}]) : h.merge(k => v) }
|
85
86
|
end
|
86
87
|
|
@@ -89,7 +90,7 @@ module Petergate
|
|
89
90
|
allowances = [rules[:all]]
|
90
91
|
current_user.roles.each do |role|
|
91
92
|
allowances << rules[role]
|
92
|
-
end if
|
93
|
+
end if user_logged_in?
|
93
94
|
allowances.flatten.compact.include?(action_name.to_sym)
|
94
95
|
end
|
95
96
|
|
@@ -97,25 +98,33 @@ module Petergate
|
|
97
98
|
current_user && current_user.has_roles?(*roles)
|
98
99
|
end
|
99
100
|
|
101
|
+
def user_logged_in?
|
102
|
+
!!current_user
|
103
|
+
end
|
104
|
+
|
100
105
|
def custom_message
|
101
106
|
defined?(self.class.controller_message) ? self.class.controller_message : 'Permission Denied'
|
102
107
|
end
|
103
108
|
|
104
109
|
def unauthorized!
|
105
110
|
respond_to do |format|
|
106
|
-
format.any(:js, :json, :xml)
|
111
|
+
format.any(:js, :json, :xml) do
|
112
|
+
head(:unauthorized)
|
113
|
+
end
|
107
114
|
format.html do
|
108
|
-
authenticate_user!
|
115
|
+
return authenticate_user!
|
109
116
|
end
|
110
117
|
end
|
111
118
|
end
|
112
119
|
|
113
120
|
def forbidden!(msg = nil)
|
114
121
|
respond_to do |format|
|
115
|
-
format.any(:js, :json, :xml)
|
122
|
+
format.any(:js, :json, :xml) do
|
123
|
+
head(:forbidden)
|
124
|
+
end
|
116
125
|
format.html do
|
117
|
-
destination = current_user.present? ? request.
|
118
|
-
redirect_to destination, notice: (msg || custom_message)
|
126
|
+
destination = current_user.present? ? request.headers['Referrer'] || after_sign_in_path_for(current_user) : root_path
|
127
|
+
redirect_to destination, notice: (msg || request.headers['msg'] || custom_message)
|
119
128
|
end
|
120
129
|
end
|
121
130
|
end
|
data/lib/petergate/version.rb
CHANGED
data/petergate.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
spec.post_install_message = "NOTICE: As of version 1.5.0, the :admin role has been changed to :root_admin."
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "
|
22
|
-
spec.add_development_dependency "rake", "~>
|
21
|
+
spec.add_development_dependency "bundler", "> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
23
23
|
spec.add_dependency 'activerecord', "> 4.0.0"
|
24
24
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: petergate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Sloan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.7'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '12.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '12.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activerecord
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,9 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
|
-
|
101
|
-
|
102
|
-
signing_key:
|
100
|
+
rubygems_version: 3.2.15
|
101
|
+
signing_key:
|
103
102
|
specification_version: 4
|
104
103
|
summary: Authorization system allowing verbose easy read controller syntax.
|
105
104
|
test_files: []
|