petergate 1.7.0 → 1.7.1

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: e312e9f0787ffa80a00fe92483d5586fbceedf70
4
- data.tar.gz: b448b04d7d3170939e6d02f6f176fcaf824819bf
3
+ metadata.gz: 4f39e620b25e925689c65db95d3b91d5edb8fc46
4
+ data.tar.gz: 6d3f0b8586c1f2bcacd7eeafdcede60b1a62c4eb
5
5
  SHA512:
6
- metadata.gz: 01d84b89a43800fc64f661bca0f6197056e6f64e7ab354620b4a5745ce153b9582691feb1c28db6bf4e1de2b45733fe519a2b5182cb73d5ba00fdbc67984a9f5
7
- data.tar.gz: 2efd020e12dfa5564b0caea81a2bd6183cc6ec55f09f34df17775e2aa4fe53347db04947a2de1ea531be39e5ce07f35ebc688e257b6c91ff690ac4e902a03066
6
+ metadata.gz: 5a0dd02c94ab67329d32a58f3db266a4e0c0991df2593a65108ea703db4f43b7727c03b76ba75f8262de03b25513a4bb668edd5efe6486ffbe542d340c935aae
7
+ data.tar.gz: d04924e4dbfb248e6ef7027571cbd023c5f64529462b6eeb5f81c4bdb9025ad19831af161a036360900b360277a5adbd221cde7d4cf6eb00e79197cd470c181b
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ dummy/tmp/*
15
15
  *.a
16
16
  mkmf.log
17
17
  *.gem
18
+ .DS_Store
data/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  Installation
14
14
  ------
15
- #####Get the gem
15
+ ##### Get the gem
16
16
  Add this line to your application's Gemfile:
17
17
 
18
18
  gem 'petergate'
@@ -24,7 +24,8 @@ And then execute:
24
24
  Or install it yourself as:
25
25
 
26
26
  gem install petergate
27
- #####Prerequisites: Setup Authentication (Devise)
27
+
28
+ ##### Prerequisites: Setup Authentication (Devise)
28
29
 
29
30
  Make sure your user model is defined in
30
31
  app/models/user.rb
@@ -37,16 +38,16 @@ If you're using [devise](https://github.com/plataformatec/devise) you're in luck
37
38
  after_sign_in_path_for(current_user)
38
39
  authenticate_user!
39
40
 
40
- #####Run the generators
41
+ ##### Run the generators
41
42
 
42
43
  rails g petergate:install
43
44
  rake db:migrate
44
-
45
- This will add a migration and insert petergate into your User model.
46
-
45
+
46
+ This will add a migration and insert petergate into your User model.
47
+
47
48
  Usage
48
49
  ------
49
- ####User Model
50
+ #### User Model
50
51
 
51
52
  Configure available roles by modifying this block at the top of your user.rb.
52
53
 
@@ -57,7 +58,7 @@ Configure available roles by modifying this block at the top of your user.rb.
57
58
  ## The :root_admin can access any page regardless of access settings. Use with caution! ##
58
59
  ## The multiple option can be set to true if you need users to have multiple roles. ##
59
60
  petergate(roles: [:admin, :editor], multiple: false) ##
60
- ############################################################################################
61
+ ############################################################################################
61
62
  ```
62
63
 
63
64
  ##### Instance Methods
@@ -71,10 +72,10 @@ user.has_roles?(:admin, :editors) # returns true if user is any of roles passed
71
72
  ```
72
73
  ##### Class Methods
73
74
 
74
- `User.role_editors => #list of editors. Method is created for all roles. role_admins, role_teachers, etc.`
75
+ `User.#{role}_editors => #list of editors. Method is created for all roles. Roles [admin, :teacher] will have corresponding methods role_admins, role_teachers, etc.`
76
+
77
+ #### Controllers
75
78
 
76
- ####Controllers
77
-
78
79
  Setup permissions in your controllers the same as you would for a before filter like so:
79
80
 
80
81
  ```ruby
@@ -103,7 +104,15 @@ def roles=(v)
103
104
  self[:roles] = v.map(&:to_sym).to_a.select{|r| r.size > 0 && ROLES.include?(r)}
104
105
  end
105
106
  ```
107
+ If you need to deny access you can use the forbidden! method:
106
108
 
109
+ ```ruby
110
+ before_action :check_active_user
111
+
112
+ def check_active_user
113
+ forbidden! unless current_user.active
114
+ end
115
+ ```
107
116
  If you want to change the `permission denied` message you can add to the access line:
108
117
 
109
118
  ```ruby
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  module Petergate
2
- VERSION = "1.7.0"
2
+ VERSION = "1.7.1"
3
3
  end
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.7.0
4
+ version: 1.7.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-07-22 00:00:00.000000000 Z
11
+ date: 2017-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,6 +67,8 @@ files:
67
67
  - LICENSE.txt
68
68
  - README.md
69
69
  - Rakefile
70
+ - assets/logo_square.png
71
+ - assets/petergate.png
70
72
  - lib/generators/petergate/install_generator.rb
71
73
  - lib/generators/petergate/templates/migrations/add_roles_to_users.rb
72
74
  - lib/petergate.rb
@@ -97,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
99
  version: '0'
98
100
  requirements: []
99
101
  rubyforge_project:
100
- rubygems_version: 2.4.5.1
102
+ rubygems_version: 2.5.1
101
103
  signing_key:
102
104
  specification_version: 4
103
105
  summary: Authorization system allowing verbose easy read controller syntax.