ae_users_legacy 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/LICENSE +20 -0
  2. data/README +47 -0
  3. data/Rakefile +49 -0
  4. data/VERSION +1 -0
  5. data/ae_users_legacy.gemspec +126 -0
  6. data/app/controllers/account_controller.rb +167 -0
  7. data/app/controllers/auth_controller.rb +202 -0
  8. data/app/controllers/permission_controller.rb +172 -0
  9. data/app/helpers/account_helper.rb +2 -0
  10. data/app/helpers/auth_helper.rb +5 -0
  11. data/app/helpers/permission_helper.rb +2 -0
  12. data/app/models/account.rb +50 -0
  13. data/app/models/auth_notifier.rb +34 -0
  14. data/app/models/auth_ticket.rb +39 -0
  15. data/app/models/email_address.rb +17 -0
  16. data/app/models/login.rb +23 -0
  17. data/app/models/open_id_identity.rb +5 -0
  18. data/app/models/permission.rb +57 -0
  19. data/app/models/person.rb +156 -0
  20. data/app/models/role.rb +7 -0
  21. data/app/views/account/_personal_info.rhtml +35 -0
  22. data/app/views/account/_procon_profile.rhtml +3 -0
  23. data/app/views/account/_signup_form.html.erb +39 -0
  24. data/app/views/account/activate.rhtml +6 -0
  25. data/app/views/account/activation_error.rhtml +11 -0
  26. data/app/views/account/change_password.rhtml +3 -0
  27. data/app/views/account/edit_profile.rhtml +117 -0
  28. data/app/views/account/signup.rhtml +9 -0
  29. data/app/views/account/signup_noactivation.rhtml +7 -0
  30. data/app/views/account/signup_success.rhtml +8 -0
  31. data/app/views/auth/_auth_form.rhtml +54 -0
  32. data/app/views/auth/_forgot_form.html.erb +12 -0
  33. data/app/views/auth/_mini_auth_form.rhtml +17 -0
  34. data/app/views/auth/_openid_auth_form.html.erb +14 -0
  35. data/app/views/auth/_other_login_options.html.erb +24 -0
  36. data/app/views/auth/auth_form.js.erb +62 -0
  37. data/app/views/auth/forgot.rhtml +3 -0
  38. data/app/views/auth/forgot_form.rhtml +6 -0
  39. data/app/views/auth/index.css.erb +23 -0
  40. data/app/views/auth/login.rhtml +6 -0
  41. data/app/views/auth/needs_activation.rhtml +6 -0
  42. data/app/views/auth/needs_person.html.erb +32 -0
  43. data/app/views/auth/needs_profile.rhtml +14 -0
  44. data/app/views/auth/openid_login.html.erb +6 -0
  45. data/app/views/auth/resend_activation.rhtml +3 -0
  46. data/app/views/auth_notifier/account_activation.rhtml +13 -0
  47. data/app/views/auth_notifier/generated_password.rhtml +10 -0
  48. data/app/views/permission/_add_grantee.rhtml +47 -0
  49. data/app/views/permission/_role_member.rhtml +8 -0
  50. data/app/views/permission/_show.rhtml +81 -0
  51. data/app/views/permission/_userpicker.rhtml +0 -0
  52. data/app/views/permission/add_role_member.rhtml +3 -0
  53. data/app/views/permission/admin.rhtml +45 -0
  54. data/app/views/permission/edit.rhtml +9 -0
  55. data/app/views/permission/edit_role.rhtml +63 -0
  56. data/app/views/permission/grant.rhtml +10 -0
  57. data/db/migrate/002_create_accounts.rb +17 -0
  58. data/db/migrate/003_create_email_addresses.rb +17 -0
  59. data/db/migrate/004_create_people.rb +24 -0
  60. data/db/migrate/013_simplify_signup.rb +15 -0
  61. data/db/migrate/014_create_permissions.rb +16 -0
  62. data/db/migrate/015_create_roles.rb +18 -0
  63. data/db/migrate/016_refactor_people.rb +36 -0
  64. data/db/migrate/017_people_permissions.rb +9 -0
  65. data/generators/ae_users/USAGE +14 -0
  66. data/generators/ae_users/ae_users_generator.rb +12 -0
  67. data/generators/ae_users/templates/add.png +0 -0
  68. data/generators/ae_users/templates/admin.png +0 -0
  69. data/generators/ae_users/templates/group.png +0 -0
  70. data/generators/ae_users/templates/logout.png +0 -0
  71. data/generators/ae_users/templates/migration.rb +25 -0
  72. data/generators/ae_users/templates/openid.gif +0 -0
  73. data/generators/ae_users/templates/remove.png +0 -0
  74. data/generators/ae_users/templates/user.png +0 -0
  75. data/init.rb +1 -0
  76. data/install.rb +1 -0
  77. data/lib/ae_users.rb +687 -0
  78. data/rails/init.rb +17 -0
  79. data/tasks/ae_users_tasks.rake +4 -0
  80. data/test/ae_users_test.rb +8 -0
  81. data/uninstall.rb +1 -0
  82. metadata +177 -0
@@ -0,0 +1,45 @@
1
+ <h1>Administration</h1>
2
+
3
+ <style type="text/css">
4
+ .permission_action {
5
+ font-size: 80%;
6
+ text-transform: uppercase;
7
+ text-decoration: none;
8
+ color: #444;
9
+ background-color: #ffc;
10
+ }
11
+ </style>
12
+
13
+ <h2>Base permissions</h2>
14
+
15
+ <blockquote>Base permissions apply to all objects of a particular type. If you grant someone base permissions on a type of object, they will be able to perform that action on any object of that type. Please choose the type of object you want to change the permissions for:</blockquote>
16
+
17
+ <ul>
18
+ <% @pclasses.each do |pc| -%>
19
+ <li>
20
+ <%= link_to pc.name.pluralize.humanize, :action => "edit", :klass => pc.name %>
21
+ </li>
22
+ <% end -%>
23
+ </ul>
24
+
25
+ <h2>Roles</h2>
26
+
27
+ <blockquote>Roles are groups of people. Roles can be given permissions just as if they were people. This can be convenient for assigning permissions to large groups of people at once. Please choose the role you want to edit:</blockquote>
28
+
29
+ <ul>
30
+ <% @roles.each do |role| -%>
31
+ <li id="role_<%= role.id%>">
32
+ <%= link_to role.name, :action => "edit_role", :id => role.id %>
33
+ <%= link_to_remote "Delete",
34
+ { :url => { :controller => "permission", :action => "delete_role", :id => role.id },
35
+ :success => "$('role_#{role.id}').remove();",
36
+ :confirm => "Are you sure you want to delete that role?" },
37
+ { :class => "permission_action" } %>
38
+ </li>
39
+ <% end -%>
40
+ </ul>
41
+
42
+ <% form_for :role, @role, :url => {:action => "create_role"} do |f| %>
43
+ New role: <%= f.text_field "name" %>
44
+ <%= submit_tag "Create" %>
45
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <h1>
2
+ <% if @item.kind_of? ActiveRecord::Base -%>
3
+ Permissions for <%=h @item.name %>
4
+ <% else -%>
5
+ Base permissions for all <%=h @item.name.pluralize %>
6
+ <% end -%>
7
+ </h1>
8
+
9
+ <%= render :partial => "show", :locals => { :item => @item } %>
@@ -0,0 +1,63 @@
1
+ <h1>Editing role <%= @role.name %></h1>
2
+
3
+ <h2>Members</h2>
4
+
5
+ <style type="text/css">
6
+ div.auto_complete {
7
+ z-index: 1000;
8
+ }
9
+
10
+ .permission_action {
11
+ font-size: 80%;
12
+ text-transform: uppercase;
13
+ text-decoration: none;
14
+ color: #444;
15
+ background-color: #ffc;
16
+ }
17
+ </style>
18
+ <%= auto_complete_stylesheet %>
19
+
20
+ <ul style="list-style-type: none;" id="members_list">
21
+ <% @role.people.each do |person| -%>
22
+ <%= render :partial => "role_member", :locals => {:person => person} %>
23
+ <% end -%>
24
+ <span id="add_member_open">
25
+ <%= link_to_function "Add member", "$('add_member_open').toggle(); $('add_member').toggle();",
26
+ :class => "permission_action" %>
27
+ </span>
28
+ <span id="add_member" style="display: none;">
29
+ <%= link_to_function "&laquo;", "$('add_member_open').toggle(); $('add_member').toggle();",
30
+ :class => "permission_action" %>
31
+ <%= user_picker "member_to_add",
32
+ :callback => "new Ajax.Updater('members_list', '#{url_for :controller => 'permission', :action => 'add_role_member',
33
+ :role => @role.id, :escape => false}',
34
+ {
35
+ parameters: { 'klass': klass, 'id': id },
36
+ insertion: Insertion.Top,
37
+ }
38
+ );" %>
39
+ </ul>
40
+
41
+ <h2>Permissions</h2>
42
+
43
+ <ul>
44
+ <% @role.permissions.each do |perm| -%>
45
+ <li>
46
+ <% if perm.permission.nil? -%>
47
+ Global superadmin
48
+ <% else -%>
49
+ <%=h perm.permission.humanize %>
50
+ <% if not perm.permissioned.nil? -%>
51
+ <%=h perm.permissioned.class %>
52
+ <% if perm.permissioned.respond_to? "name" %>
53
+ "<%=h perm.permissioned.name %>"
54
+ <% elsif perm.permissioned.respond_to? "title" %>
55
+ "<%=h perm.permissioned.title %>"
56
+ <% else -%>
57
+ #<%= perm.permissioned.id %>
58
+ <% end -%>
59
+ <% end -%>
60
+ <% end -%>
61
+ </li>
62
+ <% end -%>
63
+ </ul>
@@ -0,0 +1,10 @@
1
+ <% if @perm.grantee.kind_of? Role -%>
2
+ <%= image_tag "ae_users/group.png" %>
3
+ <% elsif @perm.grantee.kind_of? Person -%>
4
+ <%= image_tag "ae_users/user.png" %>
5
+ <% end -%>
6
+ <%= h(@perm.grantee.name) %>
7
+ <%= link_to_remote "Remove",
8
+ { :url => { :controller => "permission", :action => "revoke", :id => @perm.id },
9
+ :success => "$('grant_#{@perm.id}').remove();" },
10
+ { :class => "permission_action" } %>
@@ -0,0 +1,17 @@
1
+ class CreateAccounts < ActiveRecord::Migration
2
+ def self.up
3
+ ActiveRecord::Base.establish_connection :users
4
+ create_table :accounts do |t|
5
+ t.column :password, :string, :null => false
6
+ t.column :active, :boolean
7
+ t.column :activation_key, :string
8
+ t.column :created_at, :datetime
9
+ t.column :updated_at, :datetime
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ ActiveRecord::Base.establish_connection :users
15
+ drop_table :accounts
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ class CreateEmailAddresses < ActiveRecord::Migration
2
+ def self.up
3
+ ActiveRecord::Base.establish_connection :users
4
+ create_table :email_addresses do |t|
5
+ t.column :address, :string, :null => false
6
+ t.column :primary, :boolean
7
+ t.column :account_id, :integer, :null => false
8
+ t.column :created_at, :datetime
9
+ t.column :updated_at, :datetime
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ ActiveRecord::Base.establish_connection :users
15
+ drop_table :email_addresses
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ class CreatePeople < ActiveRecord::Migration
2
+ def self.up
3
+ ActiveRecord::Base.establish_connection :users
4
+ create_table :people do |t|
5
+ t.column :firstname, :string
6
+ t.column :lastname, :string
7
+ t.column :gender, :string
8
+ t.column :nickname, :string
9
+ t.column :address, :string
10
+ t.column :home_phone, :string
11
+ t.column :work_phone, :string
12
+ t.column :best_call_time, :string
13
+ t.column :birthdate, :datetime
14
+ t.column :account_id, :integer
15
+ t.column :created_at, :datetime
16
+ t.column :updated_at, :datetime
17
+ end
18
+ end
19
+
20
+ def self.down
21
+ ActiveRecord::Base.establish_connection :users
22
+ drop_table :people
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ class SimplifySignup < ActiveRecord::Migration
2
+ def self.up
3
+ ActiveRecord::Base.establish_connection :users
4
+ rename_column "people", "home_phone", "phone"
5
+ remove_column "people", "work_phone"
6
+ remove_column "people", "address"
7
+ end
8
+
9
+ def self.down
10
+ ActiveRecord::Base.establish_connection :users
11
+ rename_column "people", "phone", "home_phone"
12
+ add_column "people", "work_phone", :string
13
+ add_column "people", "address", :string
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ class CreatePermissions < ActiveRecord::Migration
2
+ def self.up
3
+ ActiveRecord::Base.establish_connection :users
4
+ create_table :permissions do |t|
5
+ t.column :role_id, :integer, :null => false
6
+ t.column :permission, :string
7
+ t.column :permissioned_id, :integer
8
+ t.column :permissioned_type, :string
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ ActiveRecord::Base.establish_connection :users
14
+ drop_table :permissions
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ class CreateRoles < ActiveRecord::Migration
2
+ def self.up
3
+ ActiveRecord::Base.establish_connection :users
4
+ create_table :roles do |t|
5
+ t.column :name, :string, :null => false
6
+ end
7
+ create_table :people_roles, :id => false do |t|
8
+ t.column :person_id, :integer, :null => false
9
+ t.column :role_id, :integer, :null => false
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ ActiveRecord::Base.establish_connection :users
15
+ drop_table :roles
16
+ drop_table :people_roles
17
+ end
18
+ end
@@ -0,0 +1,36 @@
1
+ class RefactorPeople < ActiveRecord::Migration
2
+ def self.up
3
+ ActiveRecord::Base.establish_connection :users
4
+ create_table :procon_profiles do |t|
5
+ t.column :person_id, :integer, :null => false
6
+ t.column :nickname, :string
7
+ t.column :phone, :string
8
+ t.column :best_call_time, :string
9
+ end
10
+ Person.find(:all).each do |person|
11
+ prof = ProconProfile.new :person => person
12
+ prof.nickname = person.nickname
13
+ prof.phone = person.phone
14
+ prof.best_call_time = person.best_call_time
15
+ prof.save
16
+ end
17
+ remove_column "people", "nickname"
18
+ remove_column "people", "phone"
19
+ remove_column "people", "best_call_time"
20
+ end
21
+
22
+ def self.down
23
+ ActiveRecord::Base.establish_connection :users
24
+ add_column "people", "nickname", :string
25
+ add_column "people", "phone", :string
26
+ add_column "people", "best_call_time", :string
27
+ ProconProfile.find(:all).each do |prof|
28
+ person = prof.person
29
+ person.nickname = prof.nickname
30
+ person.phone = prof.phone
31
+ person.best_call_time = prof.best_call_time
32
+ person.save
33
+ end
34
+ drop_table :procon_profiles
35
+ end
36
+ end
@@ -0,0 +1,9 @@
1
+ class PeoplePermissions < ActiveRecord::Migration
2
+ def self.up
3
+ add_column "permissions", "person_id", :integer
4
+ end
5
+
6
+ def self.down
7
+ remove_column "permissions", "person_id"
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ Description:
2
+ Copies the ae_users resource files into the correct place in your Rails working directory.
3
+
4
+ Example:
5
+ ./script/generate ae_users
6
+
7
+ This will create:
8
+ public/images/ae_users/add.png
9
+ public/images/ae_users/admin.png
10
+ public/images/ae_users/group.png
11
+ public/images/ae_users/logout.png
12
+ public/images/ae_users/openid.gif
13
+ public/images/ae_users/remove.png
14
+ public/images/ae_users/user.png
@@ -0,0 +1,12 @@
1
+ class AeUsersGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.directory "public/images/ae_users"
5
+ %w{add admin group logout remove user}.each do |img|
6
+ m.file "#{img}.png", "public/images/ae_users/#{img}.png"
7
+ end
8
+ m.file "openid.gif", "public/images/ae_users/openid.gif"
9
+ m.migration_template 'migration.rb', "db/migrate", :migration_file_name => 'ae_users_local_tables'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,25 @@
1
+ class AeUsersLocalTables < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :permissions do |t|
4
+ t.column :role_id, :integer
5
+ t.column :person_id, :integer
6
+ t.column :permission, :string
7
+ t.column :permissioned_id, :integer
8
+ t.column :permissioned_type, :string
9
+ end
10
+
11
+ create_table :auth_tickets do |t|
12
+ t.column :secret, :string
13
+ t.column :person_id, :integer
14
+ t.timestamps
15
+ t.column :expires_at, :datetime
16
+ end
17
+
18
+ add_index :auth_tickets, :secret, :unique => true
19
+ end
20
+
21
+ def self.down
22
+ drop_table :auth_tickets
23
+ drop_table :permissions
24
+ end
25
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'rails/init'
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here