ioquatix-account_engine 0.1.0

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.
Files changed (74) hide show
  1. data/README +0 -0
  2. data/lib/account_engine/configuration.rb +101 -0
  3. data/lib/account_engine/controller.rb +246 -0
  4. data/lib/account_engine/helper.rb +104 -0
  5. data/lib/account_engine/password.rb +432 -0
  6. data/lib/account_engine/support.rb +12 -0
  7. data/lib/account_engine/user_account/class_methods.rb +63 -0
  8. data/lib/account_engine/user_account.rb +184 -0
  9. data/lib/account_engine.rb +63 -0
  10. data/rails/app/controllers/account_controller.rb +162 -0
  11. data/rails/app/controllers/permissions_controller.rb +90 -0
  12. data/rails/app/controllers/roles_controller.rb +133 -0
  13. data/rails/app/controllers/users_controller.rb +144 -0
  14. data/rails/app/helpers/account_helper.rb +3 -0
  15. data/rails/app/helpers/permissions_helper.rb +3 -0
  16. data/rails/app/helpers/roles_helper.rb +3 -0
  17. data/rails/app/helpers/users_helper.rb +3 -0
  18. data/rails/app/models/permission.rb +129 -0
  19. data/rails/app/models/role.rb +60 -0
  20. data/rails/app/models/user.rb +5 -0
  21. data/rails/app/models/user_notify.rb +75 -0
  22. data/rails/app/views/account/_form.rhtml +8 -0
  23. data/rails/app/views/account/change_password.rhtml +17 -0
  24. data/rails/app/views/account/edit.rhtml +5 -0
  25. data/rails/app/views/account/forgot_password.rhtml +12 -0
  26. data/rails/app/views/account/home.rhtml +3 -0
  27. data/rails/app/views/account/login.rhtml +27 -0
  28. data/rails/app/views/account/logout.rhtml +8 -0
  29. data/rails/app/views/account/signup.rhtml +28 -0
  30. data/rails/app/views/permissions/_form.rhtml +14 -0
  31. data/rails/app/views/permissions/_list.rhtml +38 -0
  32. data/rails/app/views/permissions/edit.rhtml +5 -0
  33. data/rails/app/views/permissions/index.rhtml +3 -0
  34. data/rails/app/views/permissions/new.rhtml +5 -0
  35. data/rails/app/views/roles/_form.rhtml +8 -0
  36. data/rails/app/views/roles/_permissions.rhtml +25 -0
  37. data/rails/app/views/roles/edit.rhtml +5 -0
  38. data/rails/app/views/roles/index.rhtml +34 -0
  39. data/rails/app/views/roles/new.rhtml +5 -0
  40. data/rails/app/views/roles/show.rhtml +20 -0
  41. data/rails/app/views/user_notify/change_password.rhtml +10 -0
  42. data/rails/app/views/user_notify/delete.rhtml +5 -0
  43. data/rails/app/views/user_notify/forgot_password.rhtml +11 -0
  44. data/rails/app/views/user_notify/pending_delete.rhtml +9 -0
  45. data/rails/app/views/user_notify/signup.rhtml +12 -0
  46. data/rails/app/views/users/_form.rhtml +12 -0
  47. data/rails/app/views/users/edit.rhtml +5 -0
  48. data/rails/app/views/users/index.rhtml +38 -0
  49. data/rails/app/views/users/new.rhtml +5 -0
  50. data/rails/app/views/users/roles.rhtml +42 -0
  51. data/rails/app/views/users/show.rhtml +36 -0
  52. data/rails/assets/images/default/omnipotent.png +0 -0
  53. data/rails/assets/images/default/system.png +0 -0
  54. data/rails/assets/images/permissions/create.png +0 -0
  55. data/rails/assets/images/permissions/sync.png +0 -0
  56. data/rails/assets/images/roles/add_permission.png +0 -0
  57. data/rails/assets/images/roles/create.png +0 -0
  58. data/rails/assets/images/roles/edit.png +0 -0
  59. data/rails/assets/images/roles/remove_permission.png +0 -0
  60. data/rails/assets/images/roles/user.png +0 -0
  61. data/rails/assets/images/table_background.png +0 -0
  62. data/rails/assets/images/users/create.png +0 -0
  63. data/rails/assets/images/users/destroy.png +0 -0
  64. data/rails/assets/images/users/edit.png +0 -0
  65. data/rails/assets/images/users/show.png +0 -0
  66. data/rails/assets/javascripts/account_engine.js +166 -0
  67. data/rails/assets/stylesheets/account_engine.css +7 -0
  68. data/rails/assets/stylesheets/check_password.css +10 -0
  69. data/rails/assets/stylesheets/simple.css +168 -0
  70. data/rails/db/migrate/001_initial_schema.rb +49 -0
  71. data/rails/init.rb +21 -0
  72. data/rails/routes.rb +5 -0
  73. data/rails/tasks/account_engine.rake +123 -0
  74. metadata +165 -0
@@ -0,0 +1,129 @@
1
+ # Copyright (c) 2005 James Adam
2
+ #
3
+ # This is the MIT license, the license Ruby on Rails itself is licensed
4
+ # under.
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to permit
11
+ # persons to whom the Software is furnished to do so, subject to the
12
+ # following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included
15
+ # in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18
+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23
+ # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+
25
+
26
+
27
+ # The Permission class is simply a database representation of each
28
+ # controller/action pair. The association between a Role and a Permission
29
+ # instance indicates that such a Role is authorised to call the
30
+ # controller/action pair which that Permission represents.
31
+ class Permission < ActiveRecord::Base
32
+
33
+ set_table_name AccountEngine.permissions_table
34
+ has_and_belongs_to_many :roles, :join_table => AccountEngine.permissions_roles_table
35
+
36
+ validates_presence_of :controller, :action
37
+
38
+ def self.by_controller(permissions=nil)
39
+ # split it up into controllers
40
+ actions = {}
41
+ permissions ||= self.find(:all)
42
+
43
+ permissions.each do |p|
44
+ actions[p.controller] ||= []
45
+ actions[p.controller] << p
46
+ end
47
+
48
+ return actions
49
+ end
50
+
51
+ def self.inverse(controller, perms)
52
+ self.find(:all, :conditions => ['controller = ? and id not in (?)', controller, perms.map(&:id)])
53
+ end
54
+
55
+ #--
56
+ # Class methods
57
+ #++
58
+ class << self
59
+
60
+ def for(controller, action)
61
+ find :first, :conditions => ['controller = ? and action = ?', controller, action]
62
+ end
63
+
64
+ # Ensure that the table has one entry for each controller/action pair
65
+ def synchronize_with_controllers
66
+ # We need a set for mark/sweep
67
+ require 'set'
68
+
69
+ # weird hack. otherwise ActiveRecord has no idea about the superclass of any
70
+ # ActionController stuff...
71
+ require RAILS_ROOT + "/app/controllers/application"
72
+
73
+ # Load all the controller files
74
+ controller_files = Dir[RAILS_ROOT + "/app/controllers/**/*_controller.rb"]
75
+
76
+ # should we check to see if this is defined? I.E. will this code ever run
77
+ # outside of the framework environment...?
78
+ controller_files += Dir[RAILS_ROOT + "/vendor/plugins/*/app/controllers/**/*_controller.rb"]
79
+
80
+ # Search external plugins if needed. This supports gems.
81
+ if defined? Engines.plugins
82
+ Engines.plugins.each do |plugin|
83
+ plugin.code_paths.each do |path|
84
+ controller_files += Dir[File.join(path, "/**/*_controller.rb")]
85
+ end
86
+ end
87
+ end
88
+
89
+ logger.info "Controller files: " + controller_files.inspect
90
+
91
+ # we need to load all the controllers...
92
+ controller_files.each do |file_name|
93
+ require file_name #if /_controller.rb$/ =~ file_name
94
+ end
95
+
96
+ # Find the actions in each of the controllers,
97
+
98
+ marked = Set.new
99
+
100
+ ApplicationController.all_controllers.collect do |controller|
101
+ controller.new.action_method_names.each { |action|
102
+ perms = find_all_by_controller_and_action(controller.controller_path, action)
103
+
104
+ if perms.empty?
105
+ marked << self.create(:controller => controller.controller_path, :action => action, :system => true).id
106
+ else
107
+ perms.each { |p| marked << p.id }
108
+ end
109
+ }
110
+ end
111
+
112
+ # Destroy all unmarked system permissions
113
+ self.find(:all, :conditions => ['system = ?', true]).each do |p|
114
+ p.destroy unless marked.include?(p.id)
115
+ end
116
+ end
117
+
118
+ #--
119
+ # A shorthand alias
120
+ #++
121
+ alias :sync :synchronize_with_controllers
122
+
123
+ end
124
+
125
+ # Returns the full path which this Permission object represents
126
+ def path
127
+ [controller, action].join("/")
128
+ end
129
+ end
@@ -0,0 +1,60 @@
1
+ # Copyright (c) 2005 James Adam
2
+ #
3
+ # This is the MIT license, the license Ruby on Rails itself is licensed
4
+ # under.
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to permit
11
+ # persons to whom the Software is furnished to do so, subject to the
12
+ # following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included
15
+ # in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18
+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23
+ # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+
25
+
26
+
27
+ # The Role class represents an abstract set of allowable behaviours within
28
+ # an application. Each Role is associated with a number of Permissions (or
29
+ # controller/action objects), and such associations indicate what actions
30
+ # users using this application are allowed to perform.
31
+ class Role < ActiveRecord::Base
32
+ has_and_belongs_to_many :users, :class_name => "User", :join_table => AccountEngine.users_roles_table
33
+ has_and_belongs_to_many :permissions, :join_table => AccountEngine.permissions_roles_table
34
+
35
+ validates_length_of :name, :minimum => 3
36
+ validates_uniqueness_of :name
37
+
38
+ def permissions_by_controller
39
+ Permission.by_controller permissions
40
+ end
41
+
42
+ # there can only be one omnipotent role.
43
+ def validate_on_create
44
+ if self.omnipotent? && Role.find_by_omnipotent(true)
45
+ errors.add_to_base("There can only be one omnipotent role.")
46
+ end
47
+ end
48
+
49
+ set_table_name AccountEngine.roles_table
50
+
51
+ def destroy
52
+ if self.system?
53
+ raise AccountEngine::SystemProtectionError.new("Cannot destroy a system role " +
54
+ " (#{AccountEngine.guest_role_name}, #{AccountEngine.user_role_name}," +
55
+ " or #{AccountEngine.admin_role_name})")
56
+ else
57
+ super
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,5 @@
1
+ class User < ActiveRecord::Base
2
+ include AccountEngine::UserAccount
3
+
4
+ end
5
+
@@ -0,0 +1,75 @@
1
+ class UserNotify < ActionMailer::Base
2
+ def signup(user, password, url=nil)
3
+ setup_email(user)
4
+
5
+ # Email header info
6
+ @subject += "Welcome to #{AccountEngine.app_name}!"
7
+
8
+ # Email body substitutions
9
+ @body["name"] = user.fullname
10
+ @body["login"] = user.login
11
+ @body["password"] = password
12
+ @body["url"] = url || AccountEngine.app_url.to_s
13
+ @body["app_name"] = AccountEngine.app_name.to_s
14
+ end
15
+
16
+ def forgot_password(user, url=nil)
17
+ setup_email(user)
18
+
19
+ # Email header info
20
+ @subject += "Forgotten password notification"
21
+
22
+ # Email body substitutions
23
+ @body["name"] = user.fullname
24
+ @body["login"] = user.login
25
+ @body["url"] = url || AccountEngine.app_url.to_s
26
+ @body["app_name"] = AccountEngine.app_name.to_s
27
+ end
28
+
29
+ def change_password(user, password, url=nil)
30
+ setup_email(user)
31
+
32
+ # Email header info
33
+ @subject += "Changed password notification"
34
+
35
+ # Email body substitutions
36
+ @body["name"] = user.fullname
37
+ @body["login"] = user.login
38
+ @body["password"] = password
39
+ @body["url"] = url || AccountEngine.app_url.to_s
40
+ @body["app_name"] = AccountEngine.app_name.to_s
41
+ end
42
+
43
+ def pending_delete(user, url=nil)
44
+ setup_email(user)
45
+
46
+ # Email header info
47
+ @subject += "Delete user notification"
48
+
49
+ # Email body substitutions
50
+ @body["name"] = user.fullname
51
+ @body["url"] = url || AccountEngine.app_url.to_s
52
+ @body["app_name"] = AccountEngine.app_name.to_s
53
+ @body["days"] = AccountEngine.delayed_delete_days.to_s
54
+ end
55
+
56
+ def delete(user, url=nil)
57
+ setup_email(user)
58
+
59
+ # Email header info
60
+ @subject += "Delete user notification"
61
+
62
+ # Email body substitutions
63
+ @body["name"] = user.fullname
64
+ @body["url"] = url || AccountEngine.app_url.to_s
65
+ @body["app_name"] = AccountEngine.app_name.to_s
66
+ end
67
+
68
+ def setup_email(user)
69
+ @recipients = user.email.to_s
70
+ @from = AccountEngine.email_from.to_s
71
+ @subject = "#{AccountEngine.app_name}: "
72
+ @sent_on = Time.now
73
+ @headers['Content-Type'] = "text/plain; charset=#{AccountEngine.mail_charset}; format=flowed"
74
+ end
75
+ end
@@ -0,0 +1,8 @@
1
+ <% f.fieldset do %>
2
+ <%= f.error_messages %>
3
+
4
+ <%= f.text_field :email %>
5
+ <%= f.password_field :password %>
6
+
7
+ <%= f.submit %>
8
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <div title="<%= title_helper %>" class="form">
2
+ <h3>Change Password</h3>
3
+
4
+ <%= error_messages_for 'user' %>
5
+
6
+ <div class="form-padding">
7
+ <p>Enter your new password in the fields below and click 'Change Password' to have a new password sent to your email inbox.</p>
8
+
9
+ <%= start_form_tag :action => 'change_password' %>
10
+ <%= render_partial 'password', :user => @user, :submit => false %>
11
+ <div class="button-bar">
12
+ <%= submit_tag 'Change password' %>
13
+ <%= link_to 'Cancel', :action => 'home' %>
14
+ </div>
15
+ <%= end_form_tag %>
16
+ </div>
17
+ </div>
@@ -0,0 +1,5 @@
1
+ <h1>Change my account details</h1>
2
+
3
+ <% table_form_for @user, account_path do |f| %>
4
+ <%= f.render_form %>
5
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <h1>Forgotten Password</h1>
2
+
3
+ <%= error_messages_for 'user' %>
4
+
5
+ <p>Enter your email address in the field below and click 'Reset Password' to have instructions on how to retrieve your forgotten password emailed to you.</p>
6
+
7
+ <%= start_form_tag_helper %>
8
+ <label>Email Address:</label> <%= text_field_tag("email", "", "size" => 30) %>
9
+
10
+ <%= submit_tag 'Submit request' %>
11
+ <%= end_form_tag %>
12
+ </div>
@@ -0,0 +1,3 @@
1
+ <h1>Welcome <%= @user.fullname %></h1>
2
+
3
+ <%= link_to '&#171; logout', :action => 'logout' %>
@@ -0,0 +1,27 @@
1
+ <h1>Please Login</h1>
2
+
3
+ <% form_tag({:action => 'login'}, {:id => :login}) do %>
4
+ <table>
5
+ <% if flash[:login] %>
6
+ <tr>
7
+ <td><%= flash[:login] %></td>
8
+ </tr>
9
+ <% end %>
10
+ <tr>
11
+ <td>Username</td><td><%= text_field_tag "login", @login %></td>
12
+ </tr>
13
+ <tr>
14
+ <td>Password</td><td><%= password_field_tag "password" %></td>
15
+ </tr>
16
+ <tr>
17
+ <td colspan="2">
18
+ <% if AccountEngine.allow_registration? %>
19
+ <%= link_if_authorized 'Register for an account', :action => 'signup' %> |
20
+ <%= link_if_authorized 'Forgot my password', :action => 'forgot_password' %>
21
+ <% end %>
22
+ <%= submit_tag 'Login' %>
23
+ </td>
24
+ </tr>
25
+ </table>
26
+ <% end %>
27
+
@@ -0,0 +1,8 @@
1
+ <div title="<%= title_helper %>" class="memo">
2
+ <h3>Logoff</h3>
3
+
4
+ <p>You are now logged out of the system...</p>
5
+
6
+ <%= link_to '&#171; login', :action => 'login' %>
7
+ </div>
8
+
@@ -0,0 +1,28 @@
1
+ <h1>New User</h1>
2
+
3
+ <%= error_messages_for 'user' %>
4
+
5
+ <%= start_form_tag :action => 'register' %>
6
+ <table>
7
+ <tr>
8
+ <td>Login Name</td><td><%= text_field_tag "login", @login %></td>
9
+ </tr>
10
+ <tr>
11
+ <td>Email</td><td><%= text_field_tag "email", @email %></td>
12
+ </tr>
13
+ <tr>
14
+ <td>Password</td><td><%= password_field_tag "password", @password, {:onkeyup => "javascript:checkPasswords()", :id => "password"} %></td>
15
+ </tr>
16
+ <tr>
17
+ <td>Repeat Password</td>
18
+ <td id="passwordErrorStatus">
19
+ <%= password_field_tag "password", @password, {:onkeyup => "javascript:checkPasswords()", :id => "passwordCopy"} %>
20
+ </td>
21
+ </tr>
22
+ <tr>
23
+ <td colspan="2">
24
+ <%= submit_tag "Register", {:id => "passwordChangeButton"} %>
25
+ </td>
26
+ </tr>
27
+ </table>
28
+ <%= end_form_tag %>
@@ -0,0 +1,14 @@
1
+ <% f.fieldset do %>
2
+ <%= f.error_messages %>
3
+
4
+ <%= f.text_field :controller %>
5
+ <%= f.text_field :action %>
6
+
7
+ <%= f.text_field :description %>
8
+
9
+ <% if @permission.system? %>
10
+ <%= "(This is a system role. Changes may not be retained across resync)" %>
11
+ <% end %>
12
+
13
+ <%= f.submit %>
14
+ <% end %>
@@ -0,0 +1,38 @@
1
+ <table id="permission_list" class="listing">
2
+ <thead>
3
+ <tr>
4
+ <th>Controller</th>
5
+ <th> </th>
6
+ <th>Action</th>
7
+ <th> </th>
8
+ <th>Roles</th>
9
+ </tr>
10
+ </thead>
11
+ <tfoot>
12
+ <tr>
13
+ <td colspan="5">
14
+ <%= link_if_authorized icon_tag(:create) + ' New permission', :controller => 'permissions', :action => 'new' %> |
15
+ <%= link_if_authorized icon_tag(:sync) + ' Resynchronize Permissions', :controller => 'permissions', :action => 'resync' %>
16
+ </td>
17
+ </tr>
18
+ </tfoot>
19
+ <tbody>
20
+ <% controller = nil %>
21
+ <% for permission in permissions %>
22
+ <tr>
23
+ <td><%= permission.controller.humanize if permission.controller != controller %></td>
24
+ <% if permission.system? %>
25
+ <td><%= icon_tag ('system') %></td>
26
+ <td><%= permission.action %></td>
27
+ <td></td>
28
+ <% else %>
29
+ <td></td>
30
+ <td><%= link_if_authorized permission.action.humanize, :controller => 'permissions', :action => :edit, :id => permission.id %></td>
31
+ <td><%= link_if_authorized icon_tag ('destroy'), {:controller => 'permissions', :action => 'destroy', :id => permission.id}, :post => true %></td>
32
+ <% end %>
33
+ <td><%= permission.roles.collect{ |role| link_if_authorized role.name, :controller => 'roles', :action => 'show', :id => role.id }.join(', ') %></td>
34
+ </tr>
35
+ <% controller = permission.controller %>
36
+ <% end %>
37
+ </tbody>
38
+ </table>
@@ -0,0 +1,5 @@
1
+ <h1>Edit permission</h1>
2
+
3
+ <%= start_form_tag :action => 'update' %>
4
+ <%= render_partial "form" %>
5
+ <%= end_form_tag %>
@@ -0,0 +1,3 @@
1
+ <h1>Listing Permissions</h1>
2
+
3
+ <%= render :partial => 'list', :locals => {:permissions => @permissions} %>
@@ -0,0 +1,5 @@
1
+ <h1>New permission</h1>
2
+
3
+ <%= start_form_tag :action => 'create' %>
4
+ <%= render_partial "form" %>
5
+ <%= end_form_tag %>
@@ -0,0 +1,8 @@
1
+ <% f.fieldset do %>
2
+ <%= f.error_messages %>
3
+
4
+ <%= f.text_field :name %>
5
+ <%= f.text_area :description %>
6
+
7
+ <%= f.submit %>
8
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <table id="permission_list" class="listing">
2
+ <thead>
3
+ <tr>
4
+ <% actions.each_key do |c| %>
5
+ <th width="<%= 100.0 / actions.size %>%"><%= c.humanize %></th>
6
+ <% end %>
7
+ </tr>
8
+ </thead>
9
+ <tbody>
10
+ <tr class="granted">
11
+ <% actions.each_key do |c| %>
12
+ <td>
13
+ <%= actions[c].collect{ |p| link_if_authorized(icon_tag(:remove_permission), {:controller => 'roles', :action => 'remove_permission', :id => @role.id, :permission => p.id}, :method => :post) + p.action.humanize }.join("<br/>") %>
14
+ </td>
15
+ <% end%>
16
+ </tr>
17
+ <tr class="unassigned">
18
+ <% actions.each_key do |c| %>
19
+ <td>
20
+ <%= Permission.inverse(c, actions[c]).collect{ |p| link_if_authorized(icon_tag(:add_permission), {:controller => 'roles', :action => 'add_permission', :id => @role.id, :permission => p.id}, :method => :post) + p.action.humanize }.join("<br/>") %>
21
+ </td>
22
+ <% end%>
23
+ </tr>
24
+ </tbody>
25
+ </table>
@@ -0,0 +1,5 @@
1
+ <h1>Editing role '<%= @role.name %>'</h1>
2
+
3
+ <% table_form_for :role, :url => {:action => :update, :id => @role} do |f| %>
4
+ <%= f.render_form %>
5
+ <% end %>
@@ -0,0 +1,34 @@
1
+ <h1>Listing Roles</h1>
2
+
3
+ <table class="listing">
4
+ <thead>
5
+ <tr>
6
+ <th>Name</th>
7
+ <th> </th>
8
+ <th></th><th></th>
9
+ <th>Description</th>
10
+ <th>Users</th>
11
+ </tr>
12
+ </thead>
13
+ <tfoot>
14
+ <tr>
15
+ <td colspan="6">
16
+ <%= link_if_authorized icon_tag(:create) + ' New Role', new_role_path %>
17
+ </td>
18
+ </tr>
19
+ </tfoot>
20
+ <tbody>
21
+ <% @roles.each do |r| %>
22
+ <tr>
23
+ <td><%= link_if_authorized r.name, :action => 'show', :id => r.id %></td>
24
+ <td><%= link_if_authorized icon_tag('edit'), :action => 'edit', :id => r.id %></td>
25
+ <td><%= icon_tag ('system') if r.system? %></td>
26
+ <td><%= icon_tag ('omnipotent') if r.omnipotent? %></td>
27
+ <td><%= r.description %></td>
28
+ <td><%= r.users.collect { |u| link_if_authorized u.fullname, :controller => 'users', :action => 'roles', :id => u.id }.join (", ") %></td>
29
+ </tr>
30
+ <% end %>
31
+ </tbody>
32
+ </table>
33
+
34
+ <%= will_paginate @roles %>
@@ -0,0 +1,5 @@
1
+ <h1>New role</h1>
2
+
3
+ <% table_form_for :role, :url => {:action => :create} do |f| %>
4
+ <%= f.render_form %>
5
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <h1>Role: <%= @role.name %></h1>
2
+
3
+ <h2>Description</h2>
4
+
5
+ <p><%=h @role.description %> (<%= link_if_authorized 'Edit', :action => 'edit', :id => @role.id %>)</p>
6
+
7
+ <h2>Users</h2>
8
+ <ul id="role_user_list" class="property_list">
9
+ <% @role.users.each do |user| %>
10
+ <li>
11
+ <%= link_if_authorized user.fullname, {:controller => "users", :action => "roles", :id => user.id}, {:show_text => true, :title => user.login } %>
12
+ </li>
13
+ <% end %>
14
+ </ul>
15
+
16
+ <h2>Permissions</h2>
17
+ <% @actions.keys.sort.in_groups_of(4) do |controllers| %>
18
+ <% actions = @actions.dup.delete_if { |k,v| !controllers.include? k } %>
19
+ <%= render :partial => 'permissions', :locals => {:role => @role, :actions => actions} %>
20
+ <% end %>
@@ -0,0 +1,10 @@
1
+ Dear <%= @name %>,
2
+
3
+ At your request, <%= @app_name %> has changed your password. If it was not at your request, then you should be aware that someone has access to your account and requested this change.
4
+
5
+ Your new login credentials are:
6
+
7
+ login: <%= @login %>
8
+ password: <%= @password %>
9
+
10
+ <%= @url %>
@@ -0,0 +1,5 @@
1
+ Dear <%= @name %>,
2
+
3
+ At your request, <%= @app_name %> has permanently deleted your account.
4
+
5
+ <%= @url %>
@@ -0,0 +1,11 @@
1
+ Dear <%= @name %>,
2
+
3
+ At your request, <%= @app_name %> has sent you the following URL so that you may reset your password. If it was not at your request, then you should be aware that someone has entered your email address as theirs in the forgotten password section of <%= @app_name %>.
4
+
5
+ Please click on the following link to go to the change password page:
6
+
7
+ <a href="<%= @url%>">Click me!</a>
8
+
9
+ It's advisable for you to change your password as soon as you login. It's as simple as navigating to 'Preferences' and clicking on 'Change Password'.
10
+
11
+ <%= @url %>
@@ -0,0 +1,9 @@
1
+ Dear <%= @name %>,
2
+
3
+ At your request, <%= @app_name %> has marked your account for deletion. If it was not at your request, then you should be aware that someone has access to your account and requested this change.
4
+
5
+ The following link is provided for you to restore your deleted account. If you click on this link within the next <%= @days %> days, your account will not be deleted. Otherwise, simply ignore this email and your account will be permanently deleted after that time.
6
+
7
+ <a href="<%= @url%>">Click me!</a>
8
+
9
+ <%= @url %>
@@ -0,0 +1,12 @@
1
+ Welcome to <%= @app_name %>, <%= @name %>.
2
+
3
+ Your login credentials are:
4
+
5
+ login: <%= @login %>
6
+ password: <%= @password %>
7
+
8
+ Please click on the following link to confirm your registration:
9
+
10
+ <a href="<%= @url%>">Click me!</a>
11
+
12
+ <%= @url %>
@@ -0,0 +1,12 @@
1
+ <% f.fieldset do %>
2
+ <%= f.error_messages %>
3
+ <%= f.text_field :login %>
4
+ <%= f.text_field :email %>
5
+
6
+ <%= f.text_field :password %>
7
+
8
+ <%= f.check_box :verified %>
9
+ <%= f.check_box :deleted %>
10
+
11
+ <%= f.submit %>
12
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <h1>Edit User</h1>
2
+
3
+ <% table_form_for :user, :url => {:action => :update, :id => @user} do |f| %>
4
+ <%= f.render_form %>
5
+ <% end %>