mcms_authentication 0.0.2

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 (106) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +17 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/images/background/page_bg.png +0 -0
  5. data/app/assets/images/background/text_field_background.png +0 -0
  6. data/app/assets/images/icons/accept.png +0 -0
  7. data/app/assets/images/icons/add.png +0 -0
  8. data/app/assets/images/icons/application_edit.png +0 -0
  9. data/app/assets/images/icons/cancel.png +0 -0
  10. data/app/assets/images/icons/delete.png +0 -0
  11. data/app/assets/images/icons/email_go.png +0 -0
  12. data/app/assets/images/rails.png +0 -0
  13. data/app/assets/javascripts/application.js +42 -0
  14. data/app/assets/javascripts/authentication_global.js +17 -0
  15. data/app/assets/stylesheets/application.css +33 -0
  16. data/app/assets/stylesheets/authentication_global.css +424 -0
  17. data/app/controllers/application_controller.rb +36 -0
  18. data/app/controllers/home_controller.rb +44 -0
  19. data/app/controllers/roles_controller.rb +375 -0
  20. data/app/controllers/users_controller.rb +202 -0
  21. data/app/models/ability.rb +82 -0
  22. data/app/models/existing_model.rb +24 -0
  23. data/app/models/plugin.rb +30 -0
  24. data/app/models/role.rb +70 -0
  25. data/app/models/roles_user.rb +33 -0
  26. data/app/models/user.rb +90 -0
  27. data/app/views/home/index.html.erb +18 -0
  28. data/app/views/layouts/users/_javascript.html.erb +3 -0
  29. data/app/views/layouts/users/_stylesheet.html.erb +3 -0
  30. data/app/views/layouts/users/devise.html.erb +40 -0
  31. data/app/views/layouts/users/home.html.erb +99 -0
  32. data/app/views/roles/_form.html.erb +240 -0
  33. data/app/views/roles/_form.js.erb +113 -0
  34. data/app/views/roles/edit.html.erb +26 -0
  35. data/app/views/roles/index.html.erb +73 -0
  36. data/app/views/roles/new.html.erb +25 -0
  37. data/app/views/users/_role.js.erb +47 -0
  38. data/app/views/users/confirmations/new.html.erb +29 -0
  39. data/app/views/users/edit.html.erb +131 -0
  40. data/app/views/users/index.html.erb +81 -0
  41. data/app/views/users/mailer/confirmation_instructions.html.erb +22 -0
  42. data/app/views/users/mailer/reset_password_instructions.html.erb +26 -0
  43. data/app/views/users/mailer/unlock_instructions.html.erb +24 -0
  44. data/app/views/users/new.html.erb +113 -0
  45. data/app/views/users/passwords/edit.html.erb +38 -0
  46. data/app/views/users/passwords/new.html.erb +32 -0
  47. data/app/views/users/sessions/new.html.erb +84 -0
  48. data/app/views/users/shared/_links.erb +39 -0
  49. data/app/views/users/unlocks/new.html.erb +25 -0
  50. data/config/initializers/constants.rb +30 -0
  51. data/config/initializers/devise.rb +217 -0
  52. data/config/locales/devise.en.yml +57 -0
  53. data/config/locales/en.yml +10 -0
  54. data/config/routes.rb +24 -0
  55. data/db/migrate/20120605112804_devise_create_users.rb +68 -0
  56. data/db/migrate/20120608104637_create_roles.rb +30 -0
  57. data/db/migrate/20120608140424_create_roles_users.rb +25 -0
  58. data/db/migrate/20120612050932_create_plugins.rb +14 -0
  59. data/db/migrate/20120625114340_create_existing_models.rb +9 -0
  60. data/db/migrate/20120711064709_add_username_to_users.rb +9 -0
  61. data/db/seeds.rb +29 -0
  62. data/lib/generators/mcms_authentication/USAGE +8 -0
  63. data/lib/generators/mcms_authentication/mcms_authentication_generator.rb +110 -0
  64. data/lib/generators/mcms_authentication/templates/asset_manager.rb +117 -0
  65. data/lib/generators/mcms_authentication/templates/models.rb +189 -0
  66. data/lib/mcms_authentication.rb +4 -0
  67. data/lib/mcms_authentication/engine.rb +20 -0
  68. data/lib/mcms_authentication/seeds.rb +14 -0
  69. data/lib/mcms_authentication/version.rb +3 -0
  70. data/lib/tasks/mcms_authentication_tasks.rake +4 -0
  71. data/test/dummy/README.rdoc +261 -0
  72. data/test/dummy/Rakefile +7 -0
  73. data/test/dummy/app/assets/javascripts/application.js +15 -0
  74. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  75. data/test/dummy/app/controllers/application_controller.rb +3 -0
  76. data/test/dummy/app/helpers/application_helper.rb +2 -0
  77. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  78. data/test/dummy/config.ru +4 -0
  79. data/test/dummy/config/application.rb +59 -0
  80. data/test/dummy/config/boot.rb +10 -0
  81. data/test/dummy/config/database.yml +25 -0
  82. data/test/dummy/config/environment.rb +5 -0
  83. data/test/dummy/config/environments/development.rb +37 -0
  84. data/test/dummy/config/environments/production.rb +67 -0
  85. data/test/dummy/config/environments/test.rb +37 -0
  86. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  87. data/test/dummy/config/initializers/inflections.rb +15 -0
  88. data/test/dummy/config/initializers/mime_types.rb +5 -0
  89. data/test/dummy/config/initializers/secret_token.rb +7 -0
  90. data/test/dummy/config/initializers/session_store.rb +8 -0
  91. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  92. data/test/dummy/config/locales/en.yml +5 -0
  93. data/test/dummy/config/routes.rb +58 -0
  94. data/test/dummy/public/404.html +26 -0
  95. data/test/dummy/public/422.html +26 -0
  96. data/test/dummy/public/500.html +25 -0
  97. data/test/dummy/public/favicon.ico +0 -0
  98. data/test/dummy/script/rails +6 -0
  99. data/test/fixtures/existing_models.yml +11 -0
  100. data/test/functional/home_controller_test.rb +7 -0
  101. data/test/integration/navigation_test.rb +10 -0
  102. data/test/mcms_authentication_test.rb +7 -0
  103. data/test/test_helper.rb +15 -0
  104. data/test/unit/existing_model_test.rb +7 -0
  105. data/test/unit/helpers/home_helper_test.rb +4 -0
  106. metadata +234 -0
@@ -0,0 +1,18 @@
1
+ <!--
2
+
3
+ @File Name :index.html.erb
4
+
5
+ @Company Name :Mindfire Solutions Pvt. Ltd.
6
+
7
+ @Creator Name :Indranil Mukherjee
8
+
9
+ @Date Created :2012-06-04
10
+
11
+ @Date Modified :2012-06-14
12
+
13
+ @Last Modification Details :Making it as mcms project standard
14
+
15
+ @Purpose :Home page
16
+
17
+ -->
18
+
@@ -0,0 +1,3 @@
1
+ <%# AssetManager.get_libraries.each do |library| %>
2
+ <%#= javascript_include_tag library %>
3
+ <%# end %>
@@ -0,0 +1,3 @@
1
+ <% AssetManager.get_libraries.each do |library| %>
2
+ <%= stylesheet_link_tag library %>
3
+ <% end %>
@@ -0,0 +1,40 @@
1
+ <!--
2
+
3
+ @File Name :devise.html.erb
4
+
5
+ @Company Name :Mindfire Solutions Pvt. Ltd.
6
+
7
+ @Creator Name :Indranil Mukherjee
8
+
9
+ @Date Created :2012-06-04
10
+
11
+ @Date Modified :2012-06-14
12
+
13
+ @Last Modification Details :Making it as mcms project standard
14
+
15
+ @Purpose :Main layout
16
+
17
+ -->
18
+
19
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
20
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
21
+ <html xmlns="http://www.w3.org/1999/xhtml">
22
+ <head>
23
+
24
+ <title>Mcms Authentication</title>
25
+
26
+ <%= stylesheet_link_tag "authentication_global", :media => "all" %>
27
+
28
+ <%= csrf_meta_tags %>
29
+
30
+ </head>
31
+
32
+ <body>
33
+
34
+ <%= yield %>
35
+
36
+ </body>
37
+
38
+ </html>
39
+
40
+
@@ -0,0 +1,99 @@
1
+ <!--
2
+
3
+ @File Name :home.html.erb
4
+
5
+ @Company Name :Mindfire Solutions Pvt. Ltd.
6
+
7
+ @Creator Name :Indranil Mukherjee
8
+
9
+ @Date Created :2012-06-04
10
+
11
+ @Date Modified :2012-06-14
12
+
13
+ @Last Modification Details :Making it as mcms project standard
14
+
15
+ @Purpose :Custom layout
16
+
17
+ -->
18
+
19
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
20
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
21
+ <html xmlns="http://www.w3.org/1999/xhtml">
22
+
23
+ <head>
24
+
25
+ <title>Mcms Authentication</title>
26
+
27
+ <!-- Following is the stylesheets included using rails helper stylesheet_link_tag -->
28
+
29
+ <%= stylesheet_link_tag "authentication_global", :media => "all" %>
30
+
31
+ <!-- Following is the javascripts included using rails helper javascript_include_tag -->
32
+
33
+ <%= javascript_include_tag "application","authentication_global" %>
34
+
35
+
36
+ <!-- ".ui.core","ui.widget","ui.tabs" are used for tabbed pane -->
37
+ <%= render :partial => "layouts/users/javascript" %>
38
+ <!-- This is to prevent from outside forgery -->
39
+
40
+ <%= csrf_meta_tags %>
41
+
42
+ <!-- specific pages needs some javascripts -->
43
+
44
+ <%= yield :javascript %>
45
+
46
+ </head>
47
+
48
+ <body>
49
+
50
+ <div id="header">
51
+ <div id="site-bar-branding">
52
+ <span id="site-bar-company_name">
53
+ MCMS Authentication
54
+ </span>
55
+
56
+ <% if user_signed_in? %> <!-- checking if any user logged in -->
57
+
58
+ <a id="logout" href="<%= mcms_users_logout_path %>">Log out</a>
59
+
60
+ <% end %>
61
+
62
+ </div>
63
+ </div>
64
+ <% if flash[:notice] || flash[:error] %> <!-- If any notice or errors are there -->
65
+
66
+ <div id="flash-container">
67
+
68
+
69
+ <div style="visibility: visible; opacity: 1;" class="flash flash-notice" id="flash">
70
+
71
+ <%= flash[:notice] || flash[:error] %>
72
+
73
+ <a id="flash-close" href="">Close</a>
74
+
75
+ </div>
76
+
77
+ </div>
78
+
79
+ <% end %>
80
+
81
+ <div id="tabs">
82
+
83
+ <ul>
84
+
85
+ <li data-path="/mcms/users"><a id="users" href="/mcms/users" style="cursor: pointer;">Users</a></li>
86
+
87
+ <li data-path="/mcms/roles" ><a id="roles" href="/mcms/roles" style="cursor: pointer">Roles</a></li>
88
+
89
+ </ul>
90
+
91
+ </div>
92
+
93
+ <!-- yielding from views -->
94
+
95
+ <%= yield %>
96
+
97
+ </body>
98
+
99
+ </html>
@@ -0,0 +1,240 @@
1
+ <!--
2
+
3
+ @File Name :_form.html.erb
4
+
5
+ @Company Name :Mindfire Solutions Pvt. Ltd.
6
+
7
+ @Creator Name :Indranil Mukherjee
8
+
9
+ @Date Created :2012-06-04
10
+
11
+ @Date Modified :2012-06-14
12
+
13
+ @Last Modification Details :Making it as mcms project standard
14
+
15
+ @Purpose :Role form
16
+
17
+ -->
18
+
19
+ <!-- This line of code is responsible for javascript to be loaded for this particular page -->
20
+
21
+ <% content_for :javascript, render(:partial => "form.js",:locals => {:all_plugins => all_plugins}) %>
22
+
23
+
24
+ <!-- form for creating a new role -->
25
+ <%= form_for(@role) do |f| %>
26
+
27
+ <!-- If any error occured while creating a role (validation or any other) -->
28
+
29
+ <% if @role.errors.any? %>
30
+
31
+ <div id="error-explanation">
32
+
33
+ <h2><%= pluralize(@role.errors.count, "error") %> prohibited
34
+ this role from being saved:</h2>
35
+
36
+ <ul>
37
+
38
+ <% @role.errors.full_messages.each do |msg| %>
39
+
40
+ <li><%= msg %></li>
41
+
42
+ <% end %>
43
+
44
+ </ul>
45
+
46
+ </div>
47
+
48
+ <% end %>
49
+
50
+ <!-- error messages are displayed -->
51
+
52
+ <div class="field session-username clearfix">
53
+
54
+ <%= f.label :title %><br />
55
+
56
+ <%= f.text_field :title %></div>
57
+
58
+ <div id="records">
59
+
60
+ <% i = 1 %>
61
+
62
+ <% all_plugins.each do |p| %>
63
+
64
+ <div class="clearfix record <%= cycle("odd", "even") %> roles" > <!-- Showing all plugins alternative css applied -->
65
+
66
+ <span class="title">
67
+
68
+ <span class="preview">
69
+
70
+ <strong> <%= Models.get_module_name(p).classify %></strong> <!-- module -->
71
+
72
+ </span>
73
+
74
+ </span>
75
+
76
+ <!-- Access control user input of above module -->
77
+
78
+ <span class="actions">
79
+
80
+ <% r = Plugin.find_by_role_module_and_role_id(p.last,@role.id) %>
81
+
82
+
83
+ <% if r.present? %>
84
+
85
+ <% if(r.role_read?) %>
86
+
87
+ read <%= check_box_tag "#{p.last}read","1",:checked => "checked" %>
88
+
89
+ <%= hidden_field_tag "#{p.last}_read","1" %>
90
+
91
+ <% else %>
92
+
93
+ read <%= check_box_tag "#{p.last}read" %>
94
+
95
+ <%= hidden_field_tag "#{p.last}_read" %>
96
+ <% end %>
97
+
98
+ <% else %>
99
+
100
+ <% if(@role.title == "superuser") %>
101
+
102
+
103
+ read <%= check_box_tag "#{p.last}read","1",:checked => "checked" %>
104
+
105
+ <%= hidden_field_tag "#{p.last}_read","1" %>
106
+
107
+
108
+ <% else %>
109
+
110
+ read <%= check_box_tag "#{p.last}read" %>
111
+
112
+ <%= hidden_field_tag "#{p.last}_read" %>
113
+ <% end %>
114
+ <% end %>
115
+
116
+ <% if r.present? %>
117
+ <% if r.role_create? %>
118
+ create <%= check_box_tag "#{p.last}create","1",:checked => "checked" %>
119
+
120
+ <%= hidden_field_tag "#{p.last}_create","1" %>
121
+ <% else %>
122
+ create <%= check_box_tag "#{p.last}create" %>
123
+
124
+ <%= hidden_field_tag "#{p.last}_create" %>
125
+ <% end %>
126
+ <% else %>
127
+ <% if(@role.title == "superuser") %>
128
+ create <%= check_box_tag "#{p.last}create","1",:checked => "checked" %>
129
+
130
+ <%= hidden_field_tag "#{p.last}_create","1" %>
131
+ <% else %>
132
+ create <%= check_box_tag "#{p.last}create" %>
133
+
134
+ <%= hidden_field_tag "#{p.last}_create" %>
135
+ <% end %>
136
+ <% end %>
137
+
138
+ <% if r.present? %>
139
+ <% if r.role_update? %>
140
+ update <%= check_box_tag "#{p.last}update" , "1",:checked => "1" %>
141
+
142
+ <%= hidden_field_tag "#{p.last}_update","1" %>
143
+ <% else %>
144
+ update <%= check_box_tag "#{p.last}update" %>
145
+
146
+ <%= hidden_field_tag "#{p.last}_update" %>
147
+ <% end %>
148
+ <% else %>
149
+
150
+ <% if(@role.title == "superuser") %>
151
+
152
+ update <%= check_box_tag "#{p.last}update" , "1",:checked => "1" %>
153
+
154
+ <%= hidden_field_tag "#{p.last}_update","1" %>
155
+ <% else %>
156
+ update <%= check_box_tag "#{p.last}update" %>
157
+
158
+ <%= hidden_field_tag "#{p.last}_update" %>
159
+ <% end %>
160
+
161
+ <% end %>
162
+
163
+
164
+ <% if r.present? %>
165
+ <% if r.role_destroy? %>
166
+ delete <%= check_box_tag "#{p.last}destroy","1",:checked => "checked" %>
167
+
168
+ <%= hidden_field_tag "#{p.last}_destroy","1" %>
169
+
170
+ <% else %>
171
+ delete <%= check_box_tag "#{p.last}destroy" %>
172
+
173
+ <%= hidden_field_tag "#{p.last}_destroy" %>
174
+ <% end %>
175
+ <% else %>
176
+
177
+ <% if(@role.title == "superuser") %>
178
+ delete <%= check_box_tag "#{p.last}destroy","1",:checked => "checked" %>
179
+
180
+ <%= hidden_field_tag "#{p.last}_destroy","1" %>
181
+ <% else %>
182
+
183
+ delete <%= check_box_tag "#{p.last}destroy" %>
184
+
185
+ <%= hidden_field_tag "#{p.last}_destroy" %>
186
+
187
+ <% end %>
188
+ <% end %>
189
+
190
+ <% if r.present? %>
191
+ <% if r.role_manage? %>
192
+
193
+ All <%= check_box_tag "#{p.last}all","1",:checked => "checked" %>
194
+
195
+ <%= hidden_field_tag "#{p.last}_all","1" %>
196
+ <% else %>
197
+ All <%= check_box_tag "#{p.last}all" %>
198
+
199
+ <%= hidden_field_tag "#{p.last}_all" %>
200
+ <% end %>
201
+
202
+ <% else %>
203
+
204
+ <% if(@role.title == "superuser") %>
205
+ All <%= check_box_tag "#{p.last}all","1",:checked => "checked" %>
206
+
207
+ <%= hidden_field_tag "#{p.last}_all","1" %>
208
+ <% else %>
209
+
210
+ All <%= check_box_tag "#{p.last}all" %>
211
+
212
+ <%= hidden_field_tag "#{p.last}_all" %>
213
+ <% end %>
214
+ <% end %>
215
+ </span>
216
+
217
+ </div>
218
+
219
+ <% i = i+1 %>
220
+
221
+ <% end %>
222
+
223
+ </div>
224
+
225
+ <div class="form-actions" style="border-radius: 5px 5px 5px 5px;">
226
+
227
+ <div class="form-actions-left">
228
+
229
+ <%= f.submit "Save",:class => "button" %>
230
+
231
+ <%= link_to "Cancel",roles_path,:id => "cancel",:class => "close-dialog button" %>
232
+
233
+ </div>
234
+
235
+ </div>
236
+
237
+ <% end %>
238
+
239
+ <!-- End of form -->
240
+
@@ -0,0 +1,113 @@
1
+ <!--
2
+
3
+ @File Name :_form.js.erb
4
+
5
+ @Company Name :Mindfire Solutions Pvt. Ltd.
6
+
7
+ @Creator Name :Indranil Mukherjee
8
+
9
+ @Date Created :2012-06-04
10
+
11
+ @Date Modified :2012-06-14
12
+
13
+ @Last Modification Details :Making it as mcms project standard
14
+
15
+ @Purpose :The following script is responsible for role form access control data manipulation
16
+ We have used hidden field to check whether a
17
+ particular access to a particular module is given
18
+ or not.(As the checkbox is checked or not)
19
+
20
+ -->
21
+
22
+ <script type="text/javascript">
23
+
24
+ $(document).ready(function(){
25
+
26
+
27
+
28
+ var checked = "checked";
29
+
30
+ <% all_plugins.each do |p| %>
31
+
32
+ $("<%= "##{p.last}read" %>").change(function(){
33
+
34
+ if($(this).is(':checked')){
35
+
36
+ $("<%= "##{p.last}_read" %>").val("1");
37
+
38
+ }else{
39
+
40
+ $("<%= "##{p.last}_read" %>").val("0");
41
+ }
42
+
43
+ })
44
+
45
+ $("<%= "##{p.last}create" %>").change(function(){
46
+ if($(this).is(':checked')){
47
+
48
+ $("<%= "##{p.last}_create" %>").val("1");
49
+
50
+ }else{
51
+
52
+ $("<%= "##{p.last}_create" %>").val("0");
53
+ }
54
+
55
+ })
56
+
57
+ $("<%= "##{p.last}update" %>").change(function(){
58
+ if($(this).is(':checked')){
59
+
60
+ $("<%= "##{p.last}_update" %>").val("1");
61
+
62
+ }else{
63
+
64
+ $("<%= "##{p.last}_update" %>").val("0");
65
+ }
66
+
67
+ })
68
+
69
+ $("<%= "##{p.last}destroy" %>").change(function(){
70
+ if($(this).is(':checked')){
71
+
72
+ $("<%= "##{p.last}_destroy" %>").val("1");
73
+
74
+ }else{
75
+
76
+ $("<%= "##{p.last}_destroy" %>").val("0");
77
+ }
78
+
79
+ })
80
+
81
+ $("<%= "##{p.last}all" %>").change(function(){
82
+ if($(this).is(':checked')){
83
+ $("<%= "##{p.last}read" %>").attr(checked,checked);
84
+ $("<%= "##{p.last}create" %>").attr(checked,checked);
85
+ $("<%= "##{p.last}update" %>").attr(checked,checked);
86
+ $("<%= "##{p.last}destroy" %>").attr(checked,checked);
87
+ $("<%= "##{p.last}_all" %>").val("1");
88
+ $("<%= "##{p.last}_read" %>").val("1");
89
+ $("<%= "##{p.last}_create" %>").val("1");
90
+ $("<%= "##{p.last}_update" %>").val("1");
91
+ $("<%= "##{p.last}_destroy" %>").val("1");
92
+ }else{
93
+
94
+ $("<%= "##{p.last}read" %>").removeAttr(checked);
95
+ $("<%= "##{p.last}create" %>").removeAttr(checked);
96
+ $("<%= "##{p.last}update" %>").removeAttr(checked);
97
+ $("<%= "##{p.last}destroy" %>").removeAttr(checked);
98
+ $("<%= "##{p.last}_all" %>").val("0");
99
+ $("<%= "##{p.last}_read" %>").val("0");
100
+ $("<%= "##{p.last}_create" %>").val("0");
101
+ $("<%= "##{p.last}_update" %>").val("0");
102
+ $("<%= "##{p.last}_destroy" %>").val("0");
103
+ }
104
+
105
+ })
106
+ <% end %>
107
+
108
+
109
+ })
110
+
111
+ </script>
112
+
113
+ <!-- End of script -->