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,26 @@
1
+ <!--
2
+
3
+ @File Name :edit.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 :rendering the form to edit roles
16
+
17
+ -->
18
+
19
+ <div id="main-content" class="new-user-form" style="margin-top: 0px;padding-top: 21px; ">
20
+
21
+
22
+ <%= render :partial => "form",:locals => {:all_plugins => @all_plugins,:role => @role} %>
23
+
24
+ </div>
25
+
26
+ <!-- End of edit role view -->
@@ -0,0 +1,73 @@
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 :Listing all roles
16
+
17
+ -->
18
+
19
+ <div id="main-content">
20
+
21
+ <div id="records">
22
+
23
+ <div class="add-user">
24
+
25
+ <a href="<%= new_role_path %>">
26
+
27
+ <div style="float: left;">
28
+
29
+ <%= image_tag "/assets/icons/add.png" %>
30
+
31
+ </div>
32
+
33
+ <div style="float: left;padding-left: 5px;">
34
+
35
+ Add new role
36
+
37
+ </div>
38
+
39
+ </a>
40
+
41
+ </div>
42
+
43
+ <% @roles.each do |role| %>
44
+
45
+ <div class="clearfix record <%= cycle("odd", "even") %>" > <!-- alternative div css change -->
46
+
47
+ <span class="title">
48
+
49
+ <span class="preview">
50
+
51
+ <strong> <%= role.title %></strong>
52
+
53
+ </span>
54
+
55
+ </span>
56
+
57
+ <span class="actions">
58
+ <% unless role.title == "superuser" %>
59
+ <%= link_to image_tag("/assets/icons/delete.png" ,:alt=> "user_delete" ,:height => "16 px" ,:width => "16 px;"), role ,:confirm => "Are you sure u want to remove #{role.title} ?", :method => :delete %>
60
+
61
+ <%= link_to image_tag("/assets/icons/application_edit.png" ,:alt=> "User_edit" ,:height => "16 px" ,:width => "16 px;"), edit_role_path(role) %>
62
+ <% end %>
63
+ </span>
64
+
65
+ </div>
66
+
67
+ <% end %>
68
+
69
+ </div>
70
+
71
+ </div>
72
+
73
+ <!-- End of listing -->
@@ -0,0 +1,25 @@
1
+ <!--
2
+
3
+ @File Name :new.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 :A new role page
16
+
17
+ -->
18
+
19
+ <div id="main-content" class="new-user-form" style="margin-top: 0px;padding-top: 21px; ">
20
+
21
+ <%= render :partial => "form",:locals => {:all_plugins => @all_plugins,:role => @role} %>
22
+
23
+ </div>
24
+
25
+ <!-- End of new role to be created -->
@@ -0,0 +1,47 @@
1
+ <!--
2
+
3
+ @File Name :_role.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 :JS for users
16
+
17
+ -->
18
+
19
+ <script type="text/javascript">
20
+
21
+ $(document).ready(function(){
22
+
23
+ $('.checkboxes input:checkbox').each(function(){
24
+
25
+ $(this).addClass("chk_role");
26
+
27
+ })
28
+ var $unique = $('input.chk_role');
29
+
30
+ $unique.click(function() {
31
+
32
+ $('.checkboxes input:checkbox').each(function(){
33
+
34
+ $('#'+$(this).attr("id")+'_value').val("0");
35
+
36
+ })
37
+
38
+ $unique.removeAttr('checked');
39
+
40
+ $(this).attr('checked', true);
41
+
42
+ $('#'+$(this).attr("id")+'_value').val("1")
43
+ });
44
+
45
+ })
46
+ </script>
47
+
@@ -0,0 +1,29 @@
1
+ <!--
2
+
3
+ @File Name :new.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 :Confirmation instruction page
16
+
17
+ -->
18
+ <h2>Resend confirmation instructions</h2>
19
+
20
+ <%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
21
+ <%= devise_error_messages! %>
22
+
23
+ <div><%= f.label :email %><br />
24
+ <%= f.email_field :email %></div>
25
+
26
+ <div><%= f.submit "Resend confirmation instructions" %></div>
27
+ <% end %>
28
+
29
+ <%= render :partial => "devise/shared/links" %>
@@ -0,0 +1,131 @@
1
+ <!--
2
+
3
+ @File Name :edit.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 :Edit an existing user
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 => "role.js",:locals => {:all_roles => @all_roles}) %>
22
+
23
+ <!-- Editing an existing user -->
24
+
25
+ <div id="main-content" class="new-user-form" style="margin-top: 0px;padding-top: 21px; ">
26
+
27
+ <!--
28
+
29
+ The following form is responsible for editing an existing user.
30
+
31
+ -->
32
+
33
+ <%= form_for(resource, :as => resource_name, :url => mcms_update_user_path(resource_name), :html => { :method => :put }) do |f| %>
34
+
35
+ <%= devise_error_messages! %>
36
+
37
+ <div class="field session-username clearfix"><%= f.label :email %><br />
38
+
39
+ <%= f.email_field :email %>
40
+
41
+ </div>
42
+
43
+ <div class="field session-username clearfix"><%= f.label :first_name %><br />
44
+
45
+ <%= f.text_field :first_name %>
46
+
47
+ </div>
48
+
49
+ <div class="field session-username clearfix"><%= f.label :last_name %><br />
50
+
51
+ <%= f.text_field :last_name %>
52
+
53
+ </div>
54
+ <div class="field session-username clearfix"><%= f.label :password %><br/> <i>(leave blank if you don't want to change it)</i>
55
+
56
+ <br /> <br />
57
+
58
+ <%= f.password_field :password, :autocomplete => "off" %></div>
59
+
60
+ <div class="field session-username clearfix"><%= f.label :password_confirmation %>
61
+
62
+ <br />
63
+
64
+ <%= f.password_field :password_confirmation %></div>
65
+
66
+
67
+ <div class="field plugin-access">
68
+
69
+ <span class="label-with-help">
70
+
71
+ <label class="title-label">Define Roles</label>
72
+
73
+ </span>
74
+
75
+ <ul class="checkboxes" id="plugins">
76
+
77
+ <% @all_roles.each do |role| %>
78
+
79
+ <li>
80
+ <% if(@user.roles.first.title == role.title) %>
81
+
82
+ <%= check_box_tag "#{role.id}" , "1" ,:checked => "checked" %>
83
+ <%= hidden_field_tag "#{role.id}_value","1" %>
84
+ <% else %>
85
+ <%= check_box_tag "#{role.id}" %>
86
+ <%= hidden_field_tag "#{role.id}_value" %>
87
+ <% end %>
88
+
89
+
90
+
91
+ <label class="stripped"><%= role.title %></label>
92
+
93
+ </li>
94
+
95
+ <% end %>
96
+
97
+ </ul>
98
+
99
+ </div>
100
+
101
+ <%= hidden_field_tag "id",@user.id %>
102
+
103
+ <div class="form-actions" style="border-radius: 5px 5px 5px 5px;">
104
+
105
+ <div class="form-actions-left" style="width:200px;">
106
+
107
+ <%= f.submit "Save",:class => "button" %>
108
+
109
+ <%= link_to "Cancel",mcms_users_path,:id => "cancel",:class => "close-dialog button" %>
110
+
111
+ </div>
112
+
113
+ <div class="form-actions-right" >
114
+
115
+ <% unless @user.has_role? "superuser" %><!-- Superuser should not be deleted any way -->
116
+
117
+ <%= link_to "Remove",mcms_destroy_user_path(:id => @user.id), :confirm => "Are you sure u want to remove #{@user.email} ?", :method => :delete ,:class => "delete-dialog button" %>
118
+
119
+ <% end %>
120
+
121
+ </div>
122
+
123
+ </div>
124
+
125
+ <% end %>
126
+
127
+
128
+ </div>
129
+
130
+
131
+ <!-- End of edit user -->
@@ -0,0 +1,81 @@
1
+ <!--
2
+
3
+ @File Name :new.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 :All users listed here
16
+
17
+ -->
18
+
19
+ <div id="main-content">
20
+
21
+ <div id="records">
22
+
23
+ <div class="add-user">
24
+
25
+ <!-- Create a new user -->
26
+
27
+ <a href="users/new">
28
+
29
+ <div style="float: left;">
30
+
31
+ <%= image_tag "/assets/icons/add.png" %>
32
+
33
+ </div>
34
+
35
+ <div style="float: left;padding-left: 5px;">
36
+
37
+ Add new user
38
+
39
+ </div>
40
+
41
+ </a>
42
+
43
+ </div>
44
+
45
+ <% @users.each do |u| %>
46
+
47
+ <div class="clearfix record <%= cycle("odd", "even") %>" > <!-- alternative css change -->
48
+
49
+ <span class="title">
50
+
51
+ <span class="preview">
52
+
53
+ <strong><%= u.email %></strong> added <%= u.created_at.strftime(USER_CREATION_TIME_FORMAT) %>
54
+
55
+ </span>
56
+
57
+ </span>
58
+
59
+ <span class="actions">
60
+
61
+ <!-- Super user should not be deleted -->
62
+
63
+ <% unless u.has_role? "superuser" %>
64
+
65
+ <%= link_to image_tag("/assets/icons/delete.png" ,:alt=> "user_delete" ,:height => "16 px" ,:width => "16 px;"), mcms_destroy_user_path(:id => u.id) ,:confirm => "Are you sure u want to remove #{u.email} ?", :method => :delete %>
66
+
67
+
68
+
69
+ <%= link_to image_tag("/assets/icons/application_edit.png" ,:alt=> "User_edit" ,:height => "16 px" ,:width => "16 px;"), "users/edit/#{u.id}" %>
70
+ <% end %>
71
+ </span>
72
+
73
+ </div>
74
+
75
+ <% end %>
76
+
77
+ </div>
78
+
79
+ </div>
80
+
81
+ <!-- End of user listing -->
@@ -0,0 +1,22 @@
1
+ <!--
2
+
3
+ @File Name :confirmation_instructions.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 :Confirmation instruction page
16
+
17
+ -->
18
+ <p>Welcome <%= @resource.email %>!</p>
19
+
20
+ <p>You can confirm your account email through the link below:</p>
21
+
22
+ <p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
@@ -0,0 +1,26 @@
1
+ <!--
2
+
3
+ @File Name :reset_password_instructions.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 :Reset password instruction page
16
+
17
+ -->
18
+
19
+ <p>Hello <%= @resource.email %>!</p>
20
+
21
+ <p>Someone has requested a link to change your password, and you can do this through the link below.</p>
22
+
23
+ <p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
24
+
25
+ <p>If you didn't request this, please ignore this email.</p>
26
+ <p>Your password won't change until you access the link above and create a new one.</p>