authcan_easyroller 0.1.2 → 0.1.3
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.
- data/.gitignore +1 -0
- data/README.rdoc +26 -27
- data/Rakefile +4 -0
- data/VERSION +1 -1
- data/app/controllers/user_sessions_controller.rb +1 -1
- data/app/controllers/users_controller.rb +1 -1
- data/app/models/user_session.rb +6 -0
- data/app/views/user_sessions/new.html.erb +21 -11
- data/app/views/users/_form.html.erb +12 -0
- data/app/views/users/edit.html.erb +0 -2
- data/app/views/users/index.html.erb +9 -8
- data/app/views/users/new.html.erb +0 -2
- data/app/views/users/show.html.erb +3 -1
- data/authcan_easyroller.gemspec +17 -12
- data/lib/authcan_easyroller.rb +7 -1
- data/{app/controllers/authcan_easyroller_controller.rb → lib/extensions/action_controller_base.rb} +21 -16
- data/lib/extensions/cancan_ability.rb +52 -0
- data/{app/helpers/authcan_easyroller_helper.rb → lib/helpers/authcan_easyroller.rb} +0 -0
- metadata +62 -11
- data/app/models/ability.rb +0 -41
- data/examples/ability.rb +0 -41
- data/examples/application.html.erb +0 -48
- data/examples/main.css +0 -41
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -1,16 +1,3 @@
|
|
1
|
-
== Rails 3 Notes
|
2
|
-
|
3
|
-
I wanted to put this at the top so that nobody misses it. There are currently some bugs due to
|
4
|
-
Rails 3 still being in beta. As I come across these bugs, I will add them below and any workaround
|
5
|
-
if available.
|
6
|
-
|
7
|
-
* Bug #3928[https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3928] - process_parameter_filter throws an exception on array parameters
|
8
|
-
|
9
|
-
[Status:] Resolved in source control, awaiting next beta release.
|
10
|
-
[Workaround:] The code to enable parameter filtering in `lib/authcan_easyroller.rb` has been commented out until the next beta release.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
1
|
== authcan_easyroller
|
15
2
|
|
16
3
|
This is a basic Rails engine utilizing Authlogic[http://github.com/binarylogic/authlogic],
|
@@ -61,19 +48,17 @@ planned enhancements so you can get a feel of where this project will go.
|
|
61
48
|
== Installation/Setup
|
62
49
|
|
63
50
|
<b>Developers Note:</b><em>I have created an example project[http://github.com/topherfangio/authcan_easyroller-example]
|
64
|
-
if you are just looking to play with it, or if you are having trouble getting your setup to work properly
|
51
|
+
if you are just looking to play with it, or if you are having trouble getting your setup to work properly. It should
|
52
|
+
have everything necessary to get up and running quickly.</em>
|
65
53
|
|
66
54
|
Assuming you already have Rails 3 installed, installation is very simple; just install the gem and
|
67
|
-
it's dependencies!
|
55
|
+
it's dependencies will automatically be installed!
|
68
56
|
|
69
|
-
gem install
|
57
|
+
gem install authcan_easyroller
|
70
58
|
|
71
|
-
Next, add the
|
59
|
+
Next, add the dependency to your <tt>Gemfile</tt>:
|
72
60
|
|
73
|
-
gem "
|
74
|
-
gem "cancan"
|
75
|
-
gem "easy_roles"
|
76
|
-
gem "authcan_easyroller"
|
61
|
+
gem "authcan_easyroller", ">= 0.1.3"
|
77
62
|
|
78
63
|
Next, create a migration for the users:
|
79
64
|
|
@@ -120,9 +105,9 @@ Next, copy the following files to their proper locations (feel free to edit them
|
|
120
105
|
help get you started). The <tt>rails.js</tt> file at the bottom of the list is the official Rails jQuery file available
|
121
106
|
at http://github.com/rails/jquery-ujs so make sure to remove the existing <tt>rails.js</tt> file from <tt>public/javascripts</tt>.
|
122
107
|
|
123
|
-
* ability.rb[http://github.com/topherfangio/authcan_easyroller/raw/master/
|
124
|
-
* application.html.erb[http://github.com/topherfangio/authcan_easyroller/raw/master/
|
125
|
-
* main.css[http://github.com/topherfangio/authcan_easyroller/raw/master/
|
108
|
+
* ability.rb[http://github.com/topherfangio/authcan_easyroller-example/raw/master/app/models/ability.rb] -> <<APPLICATION>>/app/models/ability.rb
|
109
|
+
* application.html.erb[http://github.com/topherfangio/authcan_easyroller-example/raw/master/app/views/layouts/application.html.erb] -> <<APPLICATION>>/app/view/layouts/application.html.erb
|
110
|
+
* main.css[http://github.com/topherfangio/authcan_easyroller-example/raw/master/public/stylesheets/main.css] -> <<APPLICATION>/public/stylesheets/main.css
|
126
111
|
* rails.js[http://github.com/rails/jquery-ujs/raw/master/src/rails.js] -> <<APPLICATION>/public/javascripts/rails.js
|
127
112
|
|
128
113
|
Finally, remove <tt>public/index.html</tt> and add the following to your <tt>config/routs.rb</tt> file so that your server will load properly.
|
@@ -185,9 +170,23 @@ defining the ability. I'll get in touch with the developer to see if this can be
|
|
185
170
|
|
186
171
|
# ability.rb
|
187
172
|
|
188
|
-
|
189
|
-
|
190
|
-
can
|
173
|
+
class Ability
|
174
|
+
|
175
|
+
# Include the ability class so you can have some defaults
|
176
|
+
include AuthcanEasyroller::Ability
|
177
|
+
|
178
|
+
def initialize(current_user)
|
179
|
+
|
180
|
+
# If you override initialize, make sure to call this
|
181
|
+
# method so that you have the defaults setup
|
182
|
+
ae_ability_defaults(current_user)
|
183
|
+
|
184
|
+
# Moderator role abilities
|
185
|
+
if current_user.is_moderator?
|
186
|
+
can :visit_woot_all_day, :all
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
191
190
|
end
|
192
191
|
|
193
192
|
|
data/Rakefile
CHANGED
@@ -11,6 +11,10 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/topherfangio/authcan_easyroller"
|
12
12
|
gem.authors = ["Topher Fangio"]
|
13
13
|
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
+
|
15
|
+
gem.add_dependency "authlogic", ">= 2.1.3"
|
16
|
+
gem.add_dependency "cancan", ">= 1.0.2"
|
17
|
+
gem.add_dependency "easy_roles", ">= 1.0.0"
|
14
18
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
19
|
end
|
16
20
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/app/models/user_session.rb
CHANGED
@@ -1,27 +1,37 @@
|
|
1
1
|
<h1>Login</h1>
|
2
2
|
|
3
3
|
<% form_for @user_session, :url => user_session_path do |f| %>
|
4
|
-
|
4
|
+
<% if @user_session.errors.any? %>
|
5
|
+
<div id="error_explanation">
|
6
|
+
<h2><%= pluralize(@user_session.errors.count, "error") %> prohibited this nothing from being saved:</h2>
|
5
7
|
|
6
|
-
|
8
|
+
<ul>
|
9
|
+
<% @user_session.errors.full_messages.each do |msg| %>
|
10
|
+
<li><%= msg %></li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<div class="field">
|
7
17
|
<%= f.label :email %>
|
8
18
|
<%= f.text_field :email %>
|
9
|
-
</
|
19
|
+
</div>
|
10
20
|
|
11
|
-
<
|
21
|
+
<div class="field">
|
12
22
|
<%= f.label :password %>
|
13
23
|
<%= f.password_field :password %>
|
14
|
-
</
|
24
|
+
</div>
|
15
25
|
|
16
|
-
<
|
26
|
+
<div class="field">
|
17
27
|
<%= f.check_box :remember_me %><%= f.label :remember_me %>
|
18
|
-
</
|
28
|
+
</div>
|
19
29
|
|
20
|
-
<
|
30
|
+
<div class="actions">
|
21
31
|
<%= f.submit "Login" %>
|
22
|
-
</
|
32
|
+
</div>
|
23
33
|
|
24
|
-
<
|
34
|
+
<div>
|
25
35
|
Don't have an account yet? Why not <%= link_to "sign up", new_user_path %>!
|
26
|
-
</
|
36
|
+
</div>
|
27
37
|
<% end %>
|
@@ -1,3 +1,15 @@
|
|
1
|
+
<% if @user.errors.any? %>
|
2
|
+
<div id="error_explanation">
|
3
|
+
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this nothing from being saved:</h2>
|
4
|
+
|
5
|
+
<ul>
|
6
|
+
<% @user.errors.full_messages.each do |msg| %>
|
7
|
+
<li><%= msg %></li>
|
8
|
+
<% end %>
|
9
|
+
</ul>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
12
|
+
|
1
13
|
<%= form.hidden_field :id unless form.object.new_record? %>
|
2
14
|
|
3
15
|
<p>
|
@@ -4,25 +4,22 @@
|
|
4
4
|
<tr>
|
5
5
|
<th>Email</th>
|
6
6
|
<th>Last Seen</th>
|
7
|
-
<th
|
7
|
+
<th></th>
|
8
8
|
</tr>
|
9
9
|
|
10
10
|
<% @users.each do |user| %>
|
11
11
|
<tr>
|
12
|
-
<td><%= user.email %></td>
|
12
|
+
<td><%= link_to user.email, user %></td>
|
13
13
|
<td><%= time_ago_in_words user.last_request_at %> ago</td>
|
14
14
|
|
15
15
|
<td>
|
16
|
-
<%= link_to 'Show', user %>
|
17
|
-
|
18
16
|
<% if can? :update, user %>
|
19
|
-
<%=
|
20
|
-
<%= link_to 'Edit', edit_user_path(user) %>
|
17
|
+
<%= link_to 'edit', edit_user_path(user) %>
|
21
18
|
<% end %>
|
22
19
|
|
23
20
|
<% if can? :destroy, user %>
|
24
21
|
<%= link_separator %>
|
25
|
-
<%= link_to '
|
22
|
+
<%= link_to 'delete', user, :confirm => 'Are you sure?', :method => :delete %>
|
26
23
|
<% end %>
|
27
24
|
</td>
|
28
25
|
</tr>
|
@@ -32,4 +29,8 @@
|
|
32
29
|
|
33
30
|
<br />
|
34
31
|
|
35
|
-
|
32
|
+
<% if current_user.nil? %>
|
33
|
+
Not signed up? <%= link_to 'Register', new_user_path %> now!
|
34
|
+
<% elsif can? :manage, User %>
|
35
|
+
<%= link_to 'New User', new_user_path %>
|
36
|
+
<% end %>
|
data/authcan_easyroller.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{authcan_easyroller}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Topher Fangio"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-08-16}
|
13
13
|
s.description = %q{This is a basic Rails engine utilizing Authlogic, CanCan and Easy Roles to create a starting point for simple Rails-based applications that need authentication and authorization. }
|
14
14
|
s.email = %q{fangiotophia@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -22,11 +22,8 @@ Gem::Specification.new do |s|
|
|
22
22
|
"README.rdoc",
|
23
23
|
"Rakefile",
|
24
24
|
"VERSION",
|
25
|
-
"app/controllers/authcan_easyroller_controller.rb",
|
26
25
|
"app/controllers/user_sessions_controller.rb",
|
27
26
|
"app/controllers/users_controller.rb",
|
28
|
-
"app/helpers/authcan_easyroller_helper.rb",
|
29
|
-
"app/models/ability.rb",
|
30
27
|
"app/models/user.rb",
|
31
28
|
"app/models/user_session.rb",
|
32
29
|
"app/views/user_sessions/new.html.erb",
|
@@ -37,35 +34,43 @@ Gem::Specification.new do |s|
|
|
37
34
|
"app/views/users/show.html.erb",
|
38
35
|
"authcan_easyroller.gemspec",
|
39
36
|
"config/routes.rb",
|
40
|
-
"examples/ability.rb",
|
41
|
-
"examples/application.html.erb",
|
42
|
-
"examples/main.css",
|
43
37
|
"lib/authcan_easyroller.rb",
|
38
|
+
"lib/extensions/action_controller_base.rb",
|
39
|
+
"lib/extensions/cancan_ability.rb",
|
40
|
+
"lib/helpers/authcan_easyroller.rb",
|
44
41
|
"test/helper.rb",
|
45
42
|
"test/test_authcan_easyroller.rb"
|
46
43
|
]
|
47
44
|
s.homepage = %q{http://github.com/topherfangio/authcan_easyroller}
|
48
45
|
s.rdoc_options = ["--charset=UTF-8"]
|
49
46
|
s.require_paths = ["lib"]
|
50
|
-
s.rubygems_version = %q{1.3.
|
47
|
+
s.rubygems_version = %q{1.3.7}
|
51
48
|
s.summary = %q{Rails 3 engine for user authentication/authorization utilizing Authlogic, CanCan and EasyRoles}
|
52
49
|
s.test_files = [
|
53
50
|
"test/helper.rb",
|
54
|
-
"test/test_authcan_easyroller.rb"
|
55
|
-
"examples/ability.rb"
|
51
|
+
"test/test_authcan_easyroller.rb"
|
56
52
|
]
|
57
53
|
|
58
54
|
if s.respond_to? :specification_version then
|
59
55
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
60
56
|
s.specification_version = 3
|
61
57
|
|
62
|
-
if Gem::Version.new(Gem::
|
58
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
63
59
|
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
60
|
+
s.add_runtime_dependency(%q<authlogic>, [">= 2.1.3"])
|
61
|
+
s.add_runtime_dependency(%q<cancan>, [">= 1.0.2"])
|
62
|
+
s.add_runtime_dependency(%q<easy_roles>, [">= 1.0.0"])
|
64
63
|
else
|
65
64
|
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
65
|
+
s.add_dependency(%q<authlogic>, [">= 2.1.3"])
|
66
|
+
s.add_dependency(%q<cancan>, [">= 1.0.2"])
|
67
|
+
s.add_dependency(%q<easy_roles>, [">= 1.0.0"])
|
66
68
|
end
|
67
69
|
else
|
68
70
|
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
71
|
+
s.add_dependency(%q<authlogic>, [">= 2.1.3"])
|
72
|
+
s.add_dependency(%q<cancan>, [">= 1.0.2"])
|
73
|
+
s.add_dependency(%q<easy_roles>, [">= 1.0.0"])
|
69
74
|
end
|
70
75
|
end
|
71
76
|
|
data/lib/authcan_easyroller.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
require 'authcan_easyroller'
|
2
1
|
require 'rails'
|
3
2
|
|
3
|
+
require 'cancan'
|
4
|
+
require 'authlogic'
|
5
|
+
require 'easy_roles'
|
6
|
+
|
7
|
+
require 'extensions/action_controller_base'
|
8
|
+
require 'extensions/cancan_ability'
|
9
|
+
|
4
10
|
# AuthcanEasyroller
|
5
11
|
module AuthcanEasyroller
|
6
12
|
class Engine < Rails::Engine
|
data/{app/controllers/authcan_easyroller_controller.rb → lib/extensions/action_controller_base.rb}
RENAMED
@@ -1,19 +1,6 @@
|
|
1
|
-
|
2
|
-
helper :all # include all helpers, all the time
|
3
|
-
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
4
|
-
|
5
|
-
# Scrub sensitive parameters from your log
|
6
|
-
helper_method :current_user_session, :current_user
|
7
|
-
|
8
|
-
rescue_from CanCan::AccessDenied do |exception|
|
9
|
-
flash[:error] = exception.message
|
10
|
-
redirect_back_or_default(root_url)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Ensure there is at least one user in the system before trying to do anything
|
14
|
-
before_filter :require_one_user
|
15
|
-
after_filter :store_location
|
1
|
+
require 'action_controller'
|
16
2
|
|
3
|
+
ActionController::Base.class_eval {
|
17
4
|
private
|
18
5
|
def current_user_session
|
19
6
|
return @current_user_session if defined?(@current_user_session)
|
@@ -76,4 +63,22 @@ class AuthcanEasyrollerController < ApplicationController
|
|
76
63
|
redirect_to(session[:return_to] || default)
|
77
64
|
session[:return_to] = nil
|
78
65
|
end
|
79
|
-
|
66
|
+
}
|
67
|
+
|
68
|
+
require 'helpers/authcan_easyroller'
|
69
|
+
ActionView::Base.send :include, AuthcanEasyrollerHelper
|
70
|
+
|
71
|
+
ActionController::Base.instance_eval {
|
72
|
+
# Scrub sensitive parameters from your log
|
73
|
+
helper_method :current_user_session, :current_user
|
74
|
+
|
75
|
+
rescue_from CanCan::AccessDenied do |exception|
|
76
|
+
flash[:error] = exception.message
|
77
|
+
redirect_back_or_default(root_url)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Ensure there is at least one user in the system before trying to do anything
|
81
|
+
before_filter :require_one_user
|
82
|
+
after_filter :store_location
|
83
|
+
}
|
84
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module AuthcanEasyroller
|
2
|
+
module Ability
|
3
|
+
|
4
|
+
def ae_ability_defaults(current_user)
|
5
|
+
can :read, :all
|
6
|
+
can :manage, UserSession
|
7
|
+
|
8
|
+
if current_user
|
9
|
+
# Abilities for someone with an account (does not necessarily have a "user" role)
|
10
|
+
can [:edit], User do |user|
|
11
|
+
user == current_user
|
12
|
+
end
|
13
|
+
|
14
|
+
# User role abilities
|
15
|
+
if current_user.is_user?
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
# Moderator role abilities
|
20
|
+
if current_user.is_moderator?
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# Admin role abilities
|
25
|
+
if current_user.is_admin?
|
26
|
+
can :manage, :all
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# Developer role abilities
|
31
|
+
if current_user.is_developer?
|
32
|
+
can :manage, :all
|
33
|
+
end
|
34
|
+
else
|
35
|
+
can :create, User
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.included(base)
|
41
|
+
base.send :include, CanCan::Ability
|
42
|
+
|
43
|
+
base.class_eval {
|
44
|
+
def initialize(current_user)
|
45
|
+
ae_ability_defaults(current_user)
|
46
|
+
end
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authcan_easyroller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Topher Fangio
|
@@ -14,21 +15,71 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-08-16 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: thoughtbot-shoulda
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
30
33
|
type: :development
|
31
34
|
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: authlogic
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 13
|
44
|
+
segments:
|
45
|
+
- 2
|
46
|
+
- 1
|
47
|
+
- 3
|
48
|
+
version: 2.1.3
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: cancan
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 19
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 0
|
63
|
+
- 2
|
64
|
+
version: 1.0.2
|
65
|
+
type: :runtime
|
66
|
+
version_requirements: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: easy_roles
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 23
|
76
|
+
segments:
|
77
|
+
- 1
|
78
|
+
- 0
|
79
|
+
- 0
|
80
|
+
version: 1.0.0
|
81
|
+
type: :runtime
|
82
|
+
version_requirements: *id004
|
32
83
|
description: "This is a basic Rails engine utilizing Authlogic, CanCan and Easy Roles to create a starting point for simple Rails-based applications that need authentication and authorization. "
|
33
84
|
email: fangiotophia@gmail.com
|
34
85
|
executables: []
|
@@ -44,11 +95,8 @@ files:
|
|
44
95
|
- README.rdoc
|
45
96
|
- Rakefile
|
46
97
|
- VERSION
|
47
|
-
- app/controllers/authcan_easyroller_controller.rb
|
48
98
|
- app/controllers/user_sessions_controller.rb
|
49
99
|
- app/controllers/users_controller.rb
|
50
|
-
- app/helpers/authcan_easyroller_helper.rb
|
51
|
-
- app/models/ability.rb
|
52
100
|
- app/models/user.rb
|
53
101
|
- app/models/user_session.rb
|
54
102
|
- app/views/user_sessions/new.html.erb
|
@@ -59,10 +107,10 @@ files:
|
|
59
107
|
- app/views/users/show.html.erb
|
60
108
|
- authcan_easyroller.gemspec
|
61
109
|
- config/routes.rb
|
62
|
-
- examples/ability.rb
|
63
|
-
- examples/application.html.erb
|
64
|
-
- examples/main.css
|
65
110
|
- lib/authcan_easyroller.rb
|
111
|
+
- lib/extensions/action_controller_base.rb
|
112
|
+
- lib/extensions/cancan_ability.rb
|
113
|
+
- lib/helpers/authcan_easyroller.rb
|
66
114
|
- test/helper.rb
|
67
115
|
- test/test_authcan_easyroller.rb
|
68
116
|
has_rdoc: true
|
@@ -75,27 +123,30 @@ rdoc_options:
|
|
75
123
|
require_paths:
|
76
124
|
- lib
|
77
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
78
127
|
requirements:
|
79
128
|
- - ">="
|
80
129
|
- !ruby/object:Gem::Version
|
130
|
+
hash: 3
|
81
131
|
segments:
|
82
132
|
- 0
|
83
133
|
version: "0"
|
84
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
85
136
|
requirements:
|
86
137
|
- - ">="
|
87
138
|
- !ruby/object:Gem::Version
|
139
|
+
hash: 3
|
88
140
|
segments:
|
89
141
|
- 0
|
90
142
|
version: "0"
|
91
143
|
requirements: []
|
92
144
|
|
93
145
|
rubyforge_project:
|
94
|
-
rubygems_version: 1.3.
|
146
|
+
rubygems_version: 1.3.7
|
95
147
|
signing_key:
|
96
148
|
specification_version: 3
|
97
149
|
summary: Rails 3 engine for user authentication/authorization utilizing Authlogic, CanCan and EasyRoles
|
98
150
|
test_files:
|
99
151
|
- test/helper.rb
|
100
152
|
- test/test_authcan_easyroller.rb
|
101
|
-
- examples/ability.rb
|
data/app/models/ability.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
class Ability
|
2
|
-
include CanCan::Ability
|
3
|
-
|
4
|
-
def initialize(current_user)
|
5
|
-
can :read, :all
|
6
|
-
can :manage, UserSession
|
7
|
-
|
8
|
-
if current_user
|
9
|
-
# Abilities for someone with an account (does not necessarily have a "user" role)
|
10
|
-
can [:update, :destroy], User do |user|
|
11
|
-
user == current_user
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
# User role abilities
|
16
|
-
if current_user.is_user?
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
# Moderator role abilities
|
21
|
-
if current_user.is_moderator?
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
# Admin role abilities
|
26
|
-
if current_user.is_admin?
|
27
|
-
can :manage, :all
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
# Developer role abilities
|
32
|
-
if current_user.is_developer?
|
33
|
-
can :manage, :all
|
34
|
-
end
|
35
|
-
else
|
36
|
-
can :create, User
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
data/examples/ability.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
class Ability
|
2
|
-
include CanCan::Ability
|
3
|
-
|
4
|
-
def initialize(current_user)
|
5
|
-
can :read, :all
|
6
|
-
can :manage, UserSession
|
7
|
-
|
8
|
-
if current_user
|
9
|
-
# Abilities for someone with an account (does not necessarily have a "user" role)
|
10
|
-
can [:update, :destroy], User do |user|
|
11
|
-
user == current_user
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
# User role abilities
|
16
|
-
if current_user.is_user?
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
# Moderator role abilities
|
21
|
-
if current_user.is_moderator?
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
# Admin role abilities
|
26
|
-
if current_user.is_admin?
|
27
|
-
can :manage, :all
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
# Developer role abilities
|
32
|
-
if current_user.is_developer?
|
33
|
-
can :manage, :all
|
34
|
-
end
|
35
|
-
else
|
36
|
-
can :create, User
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<%= csrf_meta_tag %>
|
4
|
-
<script src="http://www.google.com/jsapi"></script>
|
5
|
-
<script>google.load("jquery", "1.4");</script>
|
6
|
-
|
7
|
-
<%= stylesheet_link_tag 'main' %>
|
8
|
-
<%= yield :stylesheets %>
|
9
|
-
</head>
|
10
|
-
|
11
|
-
<body>
|
12
|
-
<div id='navigation'>
|
13
|
-
<%= link_to "Users", users_path %>
|
14
|
-
</div>
|
15
|
-
|
16
|
-
<div id='userland'>
|
17
|
-
<% if current_user %>
|
18
|
-
Welcome <%= current_user.email %>!
|
19
|
-
|
20
|
-
<%= link_to "My Account", user_path(current_user) %>
|
21
|
-
<%= link_separator %>
|
22
|
-
<%= link_to "Logout", user_session_path, :method => :delete %>
|
23
|
-
<% else %>
|
24
|
-
You are not currently
|
25
|
-
<%= link_to "logged in", new_user_session_path %>.
|
26
|
-
<% end %>
|
27
|
-
</div>
|
28
|
-
|
29
|
-
<div id='flashes'>
|
30
|
-
<%= raw "<h5 class='flash error'>#{flash[:error]}</h5>" unless flash[:error].blank? %>
|
31
|
-
<%= raw "<h5 class='flash notice'>#{flash[:notice]}</h5>" unless flash[:notice].blank? %>
|
32
|
-
</div>
|
33
|
-
|
34
|
-
<div id='content'>
|
35
|
-
<%= yield %>
|
36
|
-
</div>
|
37
|
-
|
38
|
-
<div id='copyright'>
|
39
|
-
Copyright © 2010, MyCompany. All rights reserved.
|
40
|
-
</div>
|
41
|
-
|
42
|
-
<script src="http://www.google.com/jsapi"></script>
|
43
|
-
<script>google.load("jquery", "1.4");</script>
|
44
|
-
<%= javascript_include_tag 'rails' %>
|
45
|
-
|
46
|
-
<%= yield :javascript %>
|
47
|
-
</body>
|
48
|
-
</html>
|
data/examples/main.css
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
#navigation {
|
2
|
-
float: left;
|
3
|
-
margin-bottom: 10px;
|
4
|
-
}
|
5
|
-
|
6
|
-
#userland {
|
7
|
-
float: right;
|
8
|
-
margin-bottom: 10px;
|
9
|
-
}
|
10
|
-
|
11
|
-
#flashes {
|
12
|
-
clear: both;
|
13
|
-
}
|
14
|
-
|
15
|
-
#content {
|
16
|
-
margin: 10px;
|
17
|
-
}
|
18
|
-
|
19
|
-
#copyright {
|
20
|
-
text-align: center;
|
21
|
-
}
|
22
|
-
|
23
|
-
.flash {
|
24
|
-
border: 1px solid #000000;
|
25
|
-
padding: 10px;
|
26
|
-
}
|
27
|
-
|
28
|
-
.flash.error {
|
29
|
-
}
|
30
|
-
|
31
|
-
.flash.notice {
|
32
|
-
}
|
33
|
-
|
34
|
-
label {
|
35
|
-
font-weight: bold;
|
36
|
-
}
|
37
|
-
|
38
|
-
input[type=text],input[type=password],select,textarea {
|
39
|
-
clear: both;
|
40
|
-
display: block;
|
41
|
-
}
|