petergate 1.3.6 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +18 -5
- data/lib/generators/petergate/install_generator.rb +7 -5
- data/lib/petergate/action_controller/base.rb +1 -1
- data/lib/petergate/version.rb +1 -1
- data/lib/templates/rails/scaffold_controller/controller.rb +1 -1
- data/petergate.gemspec +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86c0bcdf72ac723b0ec4d8038ed27b30a2756031
|
4
|
+
data.tar.gz: 4ddf671396394b93d2767e365ec68b79f58e873f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d55d71d95b26112639009a4b1645da3a071774333adf5833251c62cb7340739d216c04ab3f0cbf80da948414f110ef669386f2970389545619d9896bb3bbb3a
|
7
|
+
data.tar.gz: 2e1ecdc2e95d9e76b87d220bf9575efbf8f9ca07823074162b1e383cd97fed56e19a8df77197d8c55c1d0dc1feefc2dae09b666d671d97a6cc72c55297f1e837
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -41,16 +41,29 @@ If you're using [devise](https://github.com/plataformatec/devise) you're in luck
|
|
41
41
|
|
42
42
|
rails g petergate:install
|
43
43
|
rake db:migrate
|
44
|
+
|
45
|
+
This will add a migration and insert petergate into your User model.
|
46
|
+
|
47
|
+
Usage
|
48
|
+
------
|
49
|
+
#####User Model
|
50
|
+
|
51
|
+
Configure available roles by modifying this block at the top of your user.rb.
|
44
52
|
|
45
|
-
This will add:
|
46
53
|
```ruby
|
47
|
-
|
54
|
+
############################################################################################
|
55
|
+
## PeterGate Roles ##
|
56
|
+
## The :user role is added by default and shouldn't be included in this list. ##
|
57
|
+
## The :root_admin can access any page regardless of access settings. Use with caution! ##
|
58
|
+
## The multiple option can be set to true if you need users to have multiple roles. ##
|
59
|
+
petergate(roles: [:admin, :editor], multiple: false) ##
|
60
|
+
############################################################################################
|
48
61
|
```
|
49
|
-
to your User model.
|
50
62
|
|
51
|
-
|
52
|
-
------
|
63
|
+
Instance methods added to your User model include: `role, roles, roles=, available_roles`
|
53
64
|
|
65
|
+
#####Controllers
|
66
|
+
|
54
67
|
Setup permissions in your controllers the same as you would for a before filter like so:
|
55
68
|
|
56
69
|
```ruby
|
@@ -17,11 +17,13 @@ module Petergate
|
|
17
17
|
inject_into_file "app/models/user.rb", after: /^class\sUser < ActiveRecord::Base/ do
|
18
18
|
<<-'RUBY'
|
19
19
|
|
20
|
-
|
21
|
-
## PeterGate Roles
|
22
|
-
## The :user role is added by default and shouldn't be included in this list.
|
23
|
-
|
24
|
-
|
20
|
+
############################################################################################
|
21
|
+
## PeterGate Roles ##
|
22
|
+
## The :user role is added by default and shouldn't be included in this list. ##
|
23
|
+
## The :root_admin can access any page regardless of access settings. Use with caution! ##
|
24
|
+
## The multiple option can be set to true if you need users to have multiple roles. ##
|
25
|
+
petergate(roles: [:admin, :editor], multiple: false) ##
|
26
|
+
############################################################################################
|
25
27
|
|
26
28
|
RUBY
|
27
29
|
end
|
@@ -57,7 +57,7 @@ module Petergate
|
|
57
57
|
base.extend(ClassMethods)
|
58
58
|
base.helper_method :logged_in?, :forbidden!
|
59
59
|
base.before_filter do
|
60
|
-
unless logged_in?(:
|
60
|
+
unless logged_in?(:root_admin)
|
61
61
|
message= defined?(check_access) ? check_access : true
|
62
62
|
if message == false || message.is_a?(String)
|
63
63
|
if user_signed_in?
|
data/lib/petergate/version.rb
CHANGED
@@ -5,7 +5,7 @@ require_dependency "<%= namespaced_file_path %>/application_controller"
|
|
5
5
|
<% module_namespacing do -%>
|
6
6
|
class <%= controller_class_name %>Controller < ApplicationController
|
7
7
|
before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
|
8
|
-
access all: [:index, :show, :new, :edit, :create, :update, :destroy]
|
8
|
+
access all: [:index, :show, :new, :edit, :create, :update, :destroy], user: :all
|
9
9
|
|
10
10
|
# GET <%= route_url %>
|
11
11
|
def index
|
data/petergate.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").delete_if{|p| p.include?("dummy/")}
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.require_paths = ["lib"]
|
19
|
+
spec.post_install_message = "NOTICE: As of version 1.5.0, the :admin role has been changed to :root_admin."
|
19
20
|
|
20
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
21
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: petergate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Sloan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,7 +80,8 @@ homepage: https://github.com/isaacsloan/petergate
|
|
80
80
|
licenses:
|
81
81
|
- MIT
|
82
82
|
metadata: {}
|
83
|
-
post_install_message:
|
83
|
+
post_install_message: 'NOTICE: As of version 1.5.0, the :admin role has been changed
|
84
|
+
to :root_admin.'
|
84
85
|
rdoc_options: []
|
85
86
|
require_paths:
|
86
87
|
- lib
|