ae_users_legacy 0.6.3 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/ae_users_legacy.gemspec +8 -7
- data/app/controllers/permission_controller.rb +4 -2
- data/app/helpers/permission_helper.rb +42 -0
- data/app/views/permission/_add_grantee.rhtml +7 -4
- data/app/views/permission/_show.rhtml +11 -17
- data/lib/ae_users.rb +15 -9
- data/rails/init.rb +1 -0
- data/schema.sql +52 -0
- metadata +6 -14
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.5
|
data/ae_users_legacy.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ae_users_legacy}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nat Budin"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-03-29}
|
13
13
|
s.description = %q{Don't use this gem. Use something written in the last couple years instead.}
|
14
14
|
s.email = %q{natbudin@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -95,6 +95,7 @@ Gem::Specification.new do |s|
|
|
95
95
|
"install.rb",
|
96
96
|
"lib/ae_users.rb",
|
97
97
|
"rails/init.rb",
|
98
|
+
"schema.sql",
|
98
99
|
"tasks/ae_users_tasks.rake",
|
99
100
|
"test/ae_users_test.rb",
|
100
101
|
"uninstall.rb"
|
@@ -102,16 +103,17 @@ Gem::Specification.new do |s|
|
|
102
103
|
s.homepage = %q{http://github.com/nbudin/ae_users}
|
103
104
|
s.rdoc_options = ["--charset=UTF-8"]
|
104
105
|
s.require_paths = ["lib"]
|
105
|
-
s.rubygems_version = %q{1.
|
106
|
+
s.rubygems_version = %q{1.3.6}
|
106
107
|
s.summary = %q{Legacy authentication/authorization framework}
|
107
108
|
s.test_files = [
|
108
109
|
"test/ae_users_test.rb"
|
109
110
|
]
|
110
111
|
|
111
112
|
if s.respond_to? :specification_version then
|
113
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
112
114
|
s.specification_version = 3
|
113
115
|
|
114
|
-
if Gem::Version.new(Gem::
|
116
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
115
117
|
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
116
118
|
s.add_runtime_dependency(%q<ruby-openid>, [">= 2.0.4"])
|
117
119
|
else
|
@@ -123,4 +125,3 @@ Gem::Specification.new do |s|
|
|
123
125
|
s.add_dependency(%q<ruby-openid>, [">= 2.0.4"])
|
124
126
|
end
|
125
127
|
end
|
126
|
-
|
@@ -29,8 +29,9 @@ class PermissionController < ApplicationController
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def auto_complete_for_permission_grantee
|
32
|
-
|
33
|
-
|
32
|
+
raw_query = params[:q] || params[:term]
|
33
|
+
if raw_query
|
34
|
+
query = raw_query.strip.downcase
|
34
35
|
liketerm = "%#{query}%"
|
35
36
|
terms = query.split
|
36
37
|
|
@@ -58,6 +59,7 @@ class PermissionController < ApplicationController
|
|
58
59
|
end
|
59
60
|
|
60
61
|
@grantees.uniq!
|
62
|
+
@grantees.compact!
|
61
63
|
else
|
62
64
|
@grantees = []
|
63
65
|
end
|
@@ -1,2 +1,44 @@
|
|
1
1
|
module PermissionHelper
|
2
|
+
def grant_url(item, perm)
|
3
|
+
url_for(:controller => 'permission', :action => 'grant', :perm => full_permission_name(item, perm),
|
4
|
+
:item_klass => item.class.name, :item_id => item.id, :escape => false)
|
5
|
+
end
|
6
|
+
|
7
|
+
def prototype_grant_callback(item, perm)
|
8
|
+
return <<-EOF
|
9
|
+
nobody = $('#{perm}_nobody');
|
10
|
+
if (nobody) {
|
11
|
+
nobody.remove();
|
12
|
+
}
|
13
|
+
new Ajax.Updater('#{perm}_insert_grants_here', '#{grant_url(item, perm)}',
|
14
|
+
{
|
15
|
+
parameters: { 'klass': klass, 'id': id },
|
16
|
+
insertion: Insertion.Bottom,
|
17
|
+
}
|
18
|
+
);
|
19
|
+
EOF
|
20
|
+
end
|
21
|
+
|
22
|
+
def jquery_grant_callback(item, perm)
|
23
|
+
return <<-EOF
|
24
|
+
$('##{perm}_nobody').remove();
|
25
|
+
$.get('#{grant_url(item, perm)}',
|
26
|
+
{ 'klass': klass, 'id': id },
|
27
|
+
function(data) {
|
28
|
+
$('##{perm}_insert_grants_here').append(data);
|
29
|
+
}
|
30
|
+
);
|
31
|
+
EOF
|
32
|
+
end
|
33
|
+
|
34
|
+
def grant_permission_user_picker(item, perm)
|
35
|
+
callback = case AeUsers.js_framework
|
36
|
+
when "prototype"
|
37
|
+
prototype_grant_callback(item, perm)
|
38
|
+
when "jquery"
|
39
|
+
jquery_grant_callback(item, perm)
|
40
|
+
end
|
41
|
+
|
42
|
+
user_picker "#{perm}_grantee", :roles => true, :callback => callback
|
43
|
+
end
|
2
44
|
end
|
@@ -39,9 +39,12 @@
|
|
39
39
|
</ul>
|
40
40
|
|
41
41
|
<% elsif AeUsers.js_framework == "jquery" -%>
|
42
|
+
<%= @grantees.collect do |grantee|
|
43
|
+
lbl = grantee.name
|
44
|
+
lbl << " (#{pluralize grantee.people.count, "person"})" if grantee.kind_of? Role
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
value = "#{grantee.class.name}:#{grantee.id}"
|
47
|
+
|
48
|
+
{ 'label' => lbl, 'value' => value }
|
49
|
+
end.to_json %>
|
47
50
|
<% end -%>
|
@@ -41,7 +41,7 @@ div.auto_complete {
|
|
41
41
|
<% if logged_in? and logged_in_person.permitted?(item, "change_permissions") and not (grant.grantee == logged_in_person) -%>
|
42
42
|
<%= link_to_remote "Remove",
|
43
43
|
{ :url => { :controller => "permission", :action => "revoke", :id => grant.id, :format => "js" },
|
44
|
-
:success => "
|
44
|
+
:success => update_page { |page| page["grant_#{grant.id}"].remove },
|
45
45
|
:confirm => "Are you sure you want to revoke that permission?",
|
46
46
|
:failure => "alert(request.responseText)" },
|
47
47
|
{ :class => "permission_action" } %>
|
@@ -54,24 +54,18 @@ div.auto_complete {
|
|
54
54
|
<% if logged_in? and logged_in_person.permitted?(item, "change_permissions") -%>
|
55
55
|
<div id="<%= perm %>_insert_grants_here" style="display: inline;"></div>
|
56
56
|
| <span id="grant_open_<%=perm%>">
|
57
|
-
<%= link_to_function "Add", "
|
58
|
-
|
57
|
+
<%= link_to_function "Add", :class => "permission_action" do |page|
|
58
|
+
page["grant_open_#{perm}"].toggle
|
59
|
+
page["grant_#{perm}"].toggle
|
60
|
+
page["#{perm}_grantee_shim"].focus
|
61
|
+
end %>
|
59
62
|
</span>
|
60
63
|
<span id="grant_<%=perm %>" style="display: none;">
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
nobody.remove();
|
67
|
-
}
|
68
|
-
new Ajax.Updater('#{perm}_insert_grants_here', '#{url_for :controller => 'permission', :action => 'grant', :perm => full_permission_name(item, perm),
|
69
|
-
:item_klass => item.class.name, :item_id => item.id, :escape => false}',
|
70
|
-
{
|
71
|
-
parameters: { 'klass': klass, 'id': id },
|
72
|
-
insertion: Insertion.Bottom,
|
73
|
-
}
|
74
|
-
);" %>
|
64
|
+
<%= link_to_function "«", :class => "permission_action" do |page|
|
65
|
+
page["grant_open_#{perm}"].toggle
|
66
|
+
page["grant_#{perm}"].toggle
|
67
|
+
end %>
|
68
|
+
<%= grant_permission_user_picker(item, perm) %>
|
75
69
|
</span>
|
76
70
|
<% end -%>
|
77
71
|
</li>
|
data/lib/ae_users.rb
CHANGED
@@ -662,18 +662,24 @@ module AeUsers
|
|
662
662
|
:url => "#{auto_complete_url}") %>
|
663
663
|
ENDRHTML
|
664
664
|
elsif AeUsers.js_framework == "jquery"
|
665
|
+
jq_domid = "##{domid}"
|
665
666
|
rhtml << <<-ENDRHTML
|
666
667
|
<script type="text/javascript">
|
667
|
-
|
668
|
-
jq_domid
|
669
|
-
$(jq_domid + "_shim").autocomplete('#{auto_complete_url}',
|
668
|
+
jQuery(function() {
|
669
|
+
jQuery("#{jq_domid}_shim").autocomplete(
|
670
670
|
{
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
671
|
+
source: '#{auto_complete_url}',
|
672
|
+
select: function(e, ui) {
|
673
|
+
if (ui.item != null) {
|
674
|
+
jQuery('#{jq_domid}_shim').val(ui.item.label);
|
675
|
+
|
676
|
+
kid = ui.item.value.split(':');
|
677
|
+
klass = kid[0];
|
678
|
+
id = kid[1];
|
679
|
+
|
680
|
+
#{options[:callback]}
|
681
|
+
}
|
682
|
+
}
|
677
683
|
}
|
678
684
|
);
|
679
685
|
});
|
data/rails/init.rb
CHANGED
@@ -5,6 +5,7 @@ require 'ae_users'
|
|
5
5
|
ActiveRecord::Base.send(:include, AeUsers::Acts::Permissioned)
|
6
6
|
ActionController::Base.send(:include, AeUsers::ControllerExtensions::RequirePermission)
|
7
7
|
ActionView::Base.send(:include, AeUsers::HelperFunctions)
|
8
|
+
ActionView::Base.send(:include, PermissionHelper)
|
8
9
|
|
9
10
|
infl = begin
|
10
11
|
Inflector
|
data/schema.sql
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
CREATE TABLE `accounts` (
|
2
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
3
|
+
`password` varchar(255) NOT NULL,
|
4
|
+
`active` tinyint(1) DEFAULT NULL,
|
5
|
+
`activation_key` varchar(255) DEFAULT NULL,
|
6
|
+
`created_at` datetime DEFAULT NULL,
|
7
|
+
`updated_at` datetime DEFAULT NULL,
|
8
|
+
`person_id` int(11) DEFAULT NULL,
|
9
|
+
PRIMARY KEY (`id`)
|
10
|
+
) ENGINE=InnoDB AUTO_INCREMENT=759 DEFAULT CHARSET=latin1;
|
11
|
+
|
12
|
+
CREATE TABLE `email_addresses` (
|
13
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
14
|
+
`address` varchar(255) NOT NULL,
|
15
|
+
`primary` tinyint(1) DEFAULT NULL,
|
16
|
+
`created_at` datetime DEFAULT NULL,
|
17
|
+
`updated_at` datetime DEFAULT NULL,
|
18
|
+
`person_id` int(11) DEFAULT NULL,
|
19
|
+
PRIMARY KEY (`id`)
|
20
|
+
) ENGINE=InnoDB AUTO_INCREMENT=791 DEFAULT CHARSET=latin1;
|
21
|
+
|
22
|
+
CREATE TABLE `open_id_identities` (
|
23
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
24
|
+
`person_id` int(11) DEFAULT NULL,
|
25
|
+
`identity_url` varchar(4000) DEFAULT NULL,
|
26
|
+
PRIMARY KEY (`id`)
|
27
|
+
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1;
|
28
|
+
|
29
|
+
CREATE TABLE `people` (
|
30
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
31
|
+
`firstname` varchar(255) DEFAULT NULL,
|
32
|
+
`lastname` varchar(255) DEFAULT NULL,
|
33
|
+
`gender` varchar(255) DEFAULT NULL,
|
34
|
+
`nickname` varchar(255) DEFAULT NULL,
|
35
|
+
`phone` varchar(255) DEFAULT NULL,
|
36
|
+
`best_call_time` varchar(255) DEFAULT NULL,
|
37
|
+
`birthdate` datetime DEFAULT NULL,
|
38
|
+
`created_at` datetime DEFAULT NULL,
|
39
|
+
`updated_at` datetime DEFAULT NULL,
|
40
|
+
PRIMARY KEY (`id`)
|
41
|
+
) ENGINE=InnoDB AUTO_INCREMENT=760 DEFAULT CHARSET=latin1;
|
42
|
+
|
43
|
+
CREATE TABLE `people_roles` (
|
44
|
+
`person_id` int(11) NOT NULL,
|
45
|
+
`role_id` int(11) NOT NULL
|
46
|
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
47
|
+
|
48
|
+
CREATE TABLE `roles` (
|
49
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
50
|
+
`name` varchar(255) NOT NULL,
|
51
|
+
PRIMARY KEY (`id`)
|
52
|
+
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ae_users_legacy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
8
|
+
- 5
|
9
|
+
version: 0.6.5
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Nat Budin
|
@@ -15,18 +14,16 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-
|
17
|
+
date: 2011-03-29 00:00:00 -04:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: thoughtbot-shoulda
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
25
|
- - ">="
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
27
|
segments:
|
31
28
|
- 0
|
32
29
|
version: "0"
|
@@ -36,11 +33,9 @@ dependencies:
|
|
36
33
|
name: ruby-openid
|
37
34
|
prerelease: false
|
38
35
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
36
|
requirements:
|
41
37
|
- - ">="
|
42
38
|
- !ruby/object:Gem::Version
|
43
|
-
hash: 7
|
44
39
|
segments:
|
45
40
|
- 2
|
46
41
|
- 0
|
@@ -136,6 +131,7 @@ files:
|
|
136
131
|
- install.rb
|
137
132
|
- lib/ae_users.rb
|
138
133
|
- rails/init.rb
|
134
|
+
- schema.sql
|
139
135
|
- tasks/ae_users_tasks.rake
|
140
136
|
- test/ae_users_test.rb
|
141
137
|
- uninstall.rb
|
@@ -149,27 +145,23 @@ rdoc_options:
|
|
149
145
|
require_paths:
|
150
146
|
- lib
|
151
147
|
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
-
none: false
|
153
148
|
requirements:
|
154
149
|
- - ">="
|
155
150
|
- !ruby/object:Gem::Version
|
156
|
-
hash: 3
|
157
151
|
segments:
|
158
152
|
- 0
|
159
153
|
version: "0"
|
160
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
155
|
requirements:
|
163
156
|
- - ">="
|
164
157
|
- !ruby/object:Gem::Version
|
165
|
-
hash: 3
|
166
158
|
segments:
|
167
159
|
- 0
|
168
160
|
version: "0"
|
169
161
|
requirements: []
|
170
162
|
|
171
163
|
rubyforge_project:
|
172
|
-
rubygems_version: 1.
|
164
|
+
rubygems_version: 1.3.6
|
173
165
|
signing_key:
|
174
166
|
specification_version: 3
|
175
167
|
summary: Legacy authentication/authorization framework
|