mcms_authentication 0.0.2 → 0.0.3

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 (35) hide show
  1. data/app/assets/images/ajax-loader.gif +0 -0
  2. data/app/assets/javascripts/application.js +2 -2
  3. data/app/assets/javascripts/validate_login.js +37 -0
  4. data/app/assets/stylesheets/authentication_global.css +1542 -319
  5. data/app/controllers/application_controller.rb +5 -2
  6. data/app/controllers/home_controller.rb +18 -1
  7. data/app/controllers/roles_controller.rb +17 -10
  8. data/app/controllers/users_controller.rb +89 -36
  9. data/app/models/user.rb +9 -4
  10. data/app/views/roles/_form.html.erb +18 -13
  11. data/app/views/roles/index.html.erb +61 -32
  12. data/app/views/users/confirmations/new.html.erb +1 -0
  13. data/app/views/users/edit.html.erb +26 -14
  14. data/app/views/users/first_user.html.erb +99 -0
  15. data/app/views/users/index.html.erb +65 -38
  16. data/app/views/users/new.html.erb +24 -10
  17. data/app/views/users/passwords/edit.html.erb +17 -1
  18. data/app/views/users/passwords/new.html.erb +18 -2
  19. data/app/views/users/sessions/new.html.erb +22 -29
  20. data/app/views/users/unlocks/new.html.erb +6 -6
  21. data/config/initializers/constants.rb +5 -6
  22. data/config/routes.rb +6 -2
  23. data/db/seeds.rb +0 -18
  24. data/lib/generators/mcms_authentication/mcms_authentication_generator.rb +38 -13
  25. data/lib/generators/mcms_authentication/templates/models.rb +16 -34
  26. data/lib/mcms_authentication/engine.rb +32 -3
  27. metadata +5 -10
  28. data/app/assets/javascripts/authentication_global.js +0 -17
  29. data/app/assets/stylesheets/application.css +0 -33
  30. data/app/views/layouts/users/_javascript.html.erb +0 -3
  31. data/app/views/layouts/users/_stylesheet.html.erb +0 -3
  32. data/app/views/layouts/users/devise.html.erb +0 -40
  33. data/app/views/layouts/users/home.html.erb +0 -99
  34. data/lib/mcms_authentication/seeds.rb +0 -14
  35. data/lib/tasks/mcms_authentication_tasks.rake +0 -4
@@ -0,0 +1,99 @@
1
+ <!--
2
+
3
+ @File Name :first_user.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-07-13
12
+
13
+ @Last Modification Details :Making it as mcms project standard
14
+
15
+ @Purpose :All users listed here
16
+
17
+ -->
18
+
19
+ <% content_for :head do %>
20
+ <%= stylesheet_link_tag "authentication_global",:media => "all" %>
21
+ <% end %>
22
+
23
+ <div id="main-content" class="new-user-form" style="margin-top: 0px;padding-top: 21px; ">
24
+
25
+ <!--
26
+
27
+ The following form is responsible
28
+ for creating a first user with email and password.
29
+
30
+ -->
31
+ <h1>Create Super User</h1><br/>
32
+
33
+ <%= form_for(:user, :url => "/mcms/users_first") do |f| %>
34
+
35
+ <div class="error">
36
+ <% if flash[:notice] %>
37
+ <div> Following error occured while creating the super user</div>
38
+ <br/>
39
+ <ul>
40
+ <% flash[:notice].each do |e| %>
41
+ <li><%= e %></li>
42
+ <% end %>
43
+ </ul>
44
+ <% end %>
45
+ </div><br/>
46
+
47
+ <div class="field">
48
+
49
+ <%= f.label :email %><br />
50
+
51
+ <%= f.email_field :email %></div>
52
+
53
+ <div class="field">
54
+
55
+ <%= f.label :first_name %><br />
56
+
57
+ <%= f.text_field :first_name %>
58
+ </div>
59
+
60
+
61
+
62
+ <div class="field">
63
+
64
+ <%= f.label :last_name %><br />
65
+
66
+ <%= f.text_field :last_name %>
67
+ </div>
68
+
69
+
70
+ <div class="field">
71
+
72
+ <%= f.label :password %><br />
73
+
74
+ <%= f.password_field :password %></div>
75
+
76
+ <div class="field"><%= f.label :password_confirmation %><br />
77
+
78
+ <%= f.password_field :password_confirmation %></div>
79
+
80
+
81
+ <div class="form-actions" >
82
+
83
+ <div class="form-actions-left" >
84
+
85
+ <%= f.submit "Save",:class => "button" %>
86
+
87
+ <%= link_to "Cancel",mcms_users_path,:id => "cancel",:class => "close-dialog button" %>
88
+
89
+ </div>
90
+
91
+ </div>
92
+
93
+
94
+ <% end %>
95
+
96
+
97
+ </div>
98
+
99
+ <!-- End of First User creation -->
@@ -8,7 +8,7 @@
8
8
 
9
9
  @Date Created :2012-06-04
10
10
 
11
- @Date Modified :2012-06-14
11
+ @Date Modified :2012-07-13
12
12
 
13
13
  @Last Modification Details :Making it as mcms project standard
14
14
 
@@ -16,66 +16,93 @@
16
16
 
17
17
  -->
18
18
 
19
- <div id="main-content">
19
+ <% content_for :head do %>
20
20
 
21
- <div id="records">
22
-
23
- <div class="add-user">
24
-
25
- <!-- Create a new user -->
21
+ <%= javascript_include_tag "application","authentication_global" %>
22
+ <%= stylesheet_link_tag "authentication_global",:media => "all" %>
26
23
 
27
- <a href="users/new">
24
+ <% end %>
28
25
 
29
- <div style="float: left;">
30
26
 
31
- <%= image_tag "/assets/icons/add.png" %>
27
+ <div class="news">
32
28
 
33
- </div>
34
29
 
35
- <div style="float: left;padding-left: 5px;">
30
+ <% @users.each do |u| %>
31
+
32
+ <div class="alert "><div class="body"><span class="mini-icon mini-icon-issue-comment"></span>
36
33
 
37
- Add new user
34
+ <div class="title" style="float: left;">
35
+ <a href="#"><%= u.first_name || u.email %></a>
36
+ <span> was added </span> about
38
37
 
39
- </div>
38
+ <time class="js-relative-date"><%= distance_of_time_in_words(u.created_at,Time.now) %> ago</time>
39
+ </div>
40
40
 
41
- </a>
41
+ <!-- Super user should not be deleted -->
42
+ <div style="float: right;">
43
+
44
+ <% unless u.has_role? "superuser" %>
42
45
 
43
- </div>
46
+ <%= 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 %>
44
47
 
45
- <% @users.each do |u| %>
46
48
 
47
- <div class="clearfix record <%= cycle("odd", "even") %>" > <!-- alternative css change -->
48
49
 
49
- <span class="title">
50
+ <%= link_to image_tag("/assets/icons/application_edit.png" ,:alt=> "User_edit" ,:height => "16 px" ,:width => "16 px;"), "users/edit/#{u.id}" %>
51
+ <% end %>
52
+ </div>
50
53
 
51
- <span class="preview">
54
+ <div style="clear: both"></div>
55
+
56
+ </div>
57
+
58
+ </div>
59
+
60
+ <% end %>
52
61
 
53
- <strong><%= u.email %></strong> added <%= u.created_at.strftime(USER_CREATION_TIME_FORMAT) %>
54
62
 
55
- </span>
63
+ </div>
56
64
 
57
- </span>
58
65
 
59
- <span class="actions">
60
66
 
61
- <!-- Super user should not be deleted -->
62
-
63
- <% unless u.has_role? "superuser" %>
64
67
 
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
+ <div id="your-repos" class="repos">
69
+ <div class="top-bar">
70
+ <h2>Quick tasks </h2>
71
+ <a class="button new-repo" href="/mcms/users/new">Add new user</a>
72
+ </div>
68
73
 
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>
74
+ <ul class="repo-list" >
75
+
76
+ <li class="public source">
77
+ <a href="/mcms/roles/">
78
+ <span class="mini-icon "></span>
79
+ <span class="owner">Roles</span><span class="repo"></span>
80
+ <span class="arrow"></span>
81
+ </a>
82
+ </li>
83
+
84
+ <li class="public source">
85
+ <a href="/mcms/users/new">
86
+ <span class="mini-icon "></span>
87
+ <span class="owner">New User</span> <span class="repo"></span>
88
+ <span class="arrow"></span>
89
+ </a>
90
+ </li>
91
+
92
+ <li class="public source">
93
+ <a href="/mcms/role/new">
94
+ <span class="mini-icon "></span>
95
+ <span class="owner">Add new role</span><span class="repo"></span>
96
+ <span class="arrow"></span>
97
+ </a>
98
+ </li>
99
+
100
+ </ul>
101
+ <div class="bottom-bar">
102
+ </div>
103
+ </div>
72
104
 
73
- </div>
74
105
 
75
- <% end %>
76
106
 
77
- </div>
78
-
79
- </div>
80
107
 
81
108
  <!-- End of user listing -->
@@ -16,9 +16,23 @@
16
16
 
17
17
  -->
18
18
 
19
+ <% content_for :head do %>
20
+
21
+ <%= javascript_include_tag "application","authentication_global" %>
22
+ <%= stylesheet_link_tag "authentication_global",:media => "all" %>
23
+
24
+ <% end %>
25
+
19
26
  <!-- This line of code is responsible for javascript to be loaded for this particular page -->
27
+ <% content_for :head do %>
28
+
29
+ <%= javascript_include_tag "application","authentication_global" %>
30
+ <%= stylesheet_link_tag "authentication_global",:media => "all" %>
31
+ <%= render(:partial => "role.js",:locals => {:all_roles => @all_roles}) %>
32
+
33
+ <% end %>
34
+
20
35
 
21
- <% content_for :javascript, render(:partial => "role.js",:locals => {:all_roles => @all_roles}) %>
22
36
 
23
37
  <div id="main-content" class="new-user-form" style="margin-top: 0px;padding-top: 21px; ">
24
38
 
@@ -28,17 +42,17 @@
28
42
  for creating a new user with email and password.
29
43
 
30
44
  -->
31
- <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
45
+ <%= form_for(:user, :url => "/mcms/users") do |f| %>
32
46
 
33
47
  <%= devise_error_messages! %>
34
48
 
35
- <div class="field session-username clearfix">
49
+ <div class="field">
36
50
 
37
51
  <%= f.label :email %><br />
38
52
 
39
53
  <%= f.email_field :email %></div>
40
54
 
41
- <div class="field session-username clearfix">
55
+ <div class="field">
42
56
 
43
57
  <%= f.label :first_name %><br />
44
58
 
@@ -46,25 +60,25 @@
46
60
 
47
61
 
48
62
 
49
- <div class="field session-username clearfix">
63
+ <div class="field">
50
64
 
51
65
  <%= f.label :last_name %><br />
52
66
 
53
67
  <%= f.text_field :last_name %></div>
54
68
 
55
69
 
56
- <div class="field session-username clearfix">
70
+ <div class="field">
57
71
 
58
72
  <%= f.label :password %><br />
59
73
 
60
74
  <%= f.password_field :password %></div>
61
75
 
62
- <div class="field session-username clearfix"><%= f.label :password_confirmation %><br />
76
+ <div class="field"><%= f.label :password_confirmation %><br />
63
77
 
64
78
  <%= f.password_field :password_confirmation %></div>
65
79
 
66
80
 
67
- <div class="field plugin-access">
81
+ <div class="field">
68
82
 
69
83
  <span class="label-with-help">
70
84
 
@@ -92,9 +106,9 @@
92
106
 
93
107
  </div>
94
108
 
95
- <div class="form-actions" style="border-radius: 5px 5px 5px 5px;">
109
+ <div class="form-actions" >
96
110
 
97
- <div class="form-actions-left">
111
+ <div class="form-actions-left" >
98
112
 
99
113
  <%= f.submit "Save",:class => "button" %>
100
114
 
@@ -15,6 +15,12 @@
15
15
  @Purpose :Passwords edit page
16
16
 
17
17
  -->
18
+
19
+ <% content_for :head do %>
20
+ <%= javascript_include_tag "application","authentication_global" %>
21
+ <%= stylesheet_link_tag "authentication_global",:media => "all" %>
22
+
23
+ <% end %>
18
24
  <h2>Change your password</h2>
19
25
 
20
26
  <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
@@ -31,7 +37,17 @@
31
37
 
32
38
  <%= f.password_field :password_confirmation %></div>
33
39
 
34
- <div><%= f.submit "Change my password" %></div>
40
+ <div><div class="form-actions" style="border-radius: 5px 5px 5px 5px;margin-top:20px;height: 35px;background-color: #EAEAEA;">
41
+
42
+ <div class="form-actions-left" style="float: left;margin-left: 10px;margin-top: 8px;">
43
+
44
+ <%= f.submit "save",:class => "button" %>
45
+
46
+
47
+
48
+ </div>
49
+
50
+ </div></div>
35
51
 
36
52
  <% end %>
37
53
 
@@ -15,6 +15,12 @@
15
15
  @Purpose :new password page
16
16
 
17
17
  -->
18
+
19
+ <% content_for :head do %>
20
+ <%= javascript_include_tag "application","authentication_global" %>
21
+ <%= stylesheet_link_tag "authentication_global",:media => "all" %>
22
+
23
+ <% end %>
18
24
  <div id="main-content" class="new-user-form" style="margin-top: 0px;padding-top: 21px; ">
19
25
 
20
26
  <h2>Forgot your password?</h2>
@@ -22,10 +28,20 @@
22
28
  <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
23
29
  <%= devise_error_messages! %>
24
30
 
25
- <div><%= f.label :email %><br />
31
+ <div class="field"><%= f.label :email %><br />
26
32
  <%= f.email_field :email %></div>
27
33
 
28
- <div><%= f.submit "Send me reset password instructions" %></div>
34
+ <div><div class="form-actions" style="border-radius: 5px 5px 5px 5px;margin-top:20px;height: 35px;background-color: #EAEAEA;">
35
+
36
+ <div class="form-actions-left" style="float: left;margin-left: 10px;margin-top: 8px;">
37
+
38
+ <%= f.submit "send reset password instructions",:class => "button" %>
39
+
40
+
41
+
42
+ </div>
43
+
44
+ </div></div>
29
45
  <% end %>
30
46
 
31
47
 
@@ -1,39 +1,26 @@
1
1
  <!--
2
- **************************************************************************************************************
3
2
 
4
- FileName: new.html.erb
3
+ @FileName: new.html.erb
5
4
 
6
- Company Name and Copyright information: Mindfire Solutions Pvt. Ltd.
5
+ @Company Name and Copyright information: Mindfire Solutions Pvt. Ltd.
7
6
 
8
- Creator name and date: Indranil Mukherjee 04/06/2012
7
+ @Creator name and date: Indranil Mukherjee 04/06/2012
9
8
 
10
- Description of the file contents: Sign in page
9
+ @Description of the file contents: Sign in page
11
10
 
12
11
 
13
- **************************************************************************************************************
14
12
  -->
13
+ <% content_for :head do %>
14
+ <%= javascript_include_tag "application","authentication_global","validate_login" %>
15
+ <%= stylesheet_link_tag "authentication_global",:media => "all" %>
15
16
 
17
+ <% end %>
18
+ <p class="notice"></p>
16
19
  <div class="new-session" >
17
20
 
18
21
  <h2><%= t(:sign_in,:default => "Please Sign in") %></h2>
19
22
 
20
23
  <div id="logincontainer" style="margin-top: 10px;">
21
-
22
- <!--<div style="visibility: visible; opacity: 1;margin-top: 20px;margin-left: 5px;margin-right: 5px;margin-bottom: 20px; " class="mcms_flash mcms_flash_notice" id="mcms_flash">
23
-
24
- <%#= t(:default_uname) %> '<strong></strong>'
25
-
26
- <a id="mcms_flash_close" href="#">Close</a>
27
-
28
-
29
-
30
- </div>-->
31
-
32
- <!--
33
-
34
- The following form is responsible for sign in
35
-
36
- -->
37
24
 
38
25
  <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
39
26
 
@@ -51,26 +38,32 @@
51
38
 
52
39
  <% if devise_mapping.rememberable? -%>
53
40
 
54
- <div class="remembers">
41
+ <div style="width: 100%;">
55
42
 
56
- <div style="float: left"><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
43
+ <div style="float: left;width: 12%;margin-top:20px;" >
44
+ <div style="float: left"><%= f.check_box :remember_me %></div>
45
+ <div style="float: right;margin-top: -20px;"><%= f.label :remember_me %></div>
46
+ <div style="clear: both"></div>
47
+ </div>
57
48
 
58
- <div style="float: right; font-weight: normal;"><%= link_to "Forgot your password?", new_password_path(resource_name) ,:style => "margin-right: 5px;" %></div>
49
+ <div style="float: right; font-weight: normal;text-decoration: none"><%= link_to "Forgot your password?", new_password_path(resource_name) ,:style => "margin-right: 5px;" %></div>
59
50
 
60
- <div style="clear: both"/>
51
+ <div style="clear: both"></div>
61
52
 
62
53
  </div>
63
54
 
64
55
  <% end -%>
65
56
 
66
- <div class="form-actions">
57
+ <div class="form-actions">
67
58
 
68
- <div class="form-actions-left"><%= f.submit "Sign in" ,:class => "button"%>
59
+ <div class="form-actions-left"><%= f.submit "Sign in" ,:class => "button"%><%= image_tag "/assets/ajax-loader.gif",:id => "login_loader",:style => "display:none;padding-left:10px;" %>
69
60
 
70
61
  </div>
71
62
 
72
63
  <div class="form-actions-right">
73
-
64
+ <% if User.all.empty? %>
65
+ <%= link_to "First User" , "/mcms/first_user" %>
66
+ <% end %>
74
67
  </div>
75
68
 
76
69
  </div>
@@ -1,16 +1,16 @@
1
1
  <!--
2
- **************************************************************************************************************
3
2
 
4
- FileName: new.html.erb
5
3
 
6
- Company Name and Copyright information: Mindfire Solutions Pvt. Ltd.
4
+ @FileName: new.html.erb
7
5
 
8
- Creator name and date: Indranil Mukherjee 04/06/2012
6
+ @Company Name and Copyright information: Mindfire Solutions Pvt. Ltd.
7
+
8
+ @Creator name and date: Indranil Mukherjee 04/06/2012
9
+
10
+ @Description of the file contents: Reset unlock instructions page
9
11
 
10
- Description of the file contents: Reset unlock instructions page
11
12
 
12
13
 
13
- **************************************************************************************************************
14
14
  -->
15
15
  <h2>Resend unlock instructions</h2>
16
16
 
@@ -1,14 +1,13 @@
1
1
  =begin
2
- *************************************************************************************************************
3
- FileName: constants.rb
4
2
 
5
- Company Name and Copyright information: Mindfire Solutions Pvt. Ltd.
3
+ @FileName: constants.rb
6
4
 
7
- Creator name and date: Indranil Mukherjee 07/06/2012
5
+ @Company Name and Copyright information: Mindfire Solutions Pvt. Ltd.
8
6
 
9
- Description of the file contents: This is containing the constants which are used globally
7
+ @Creator name and date: Indranil Mukherjee 07/06/2012
8
+
9
+ @Description of the file contents: This is containing the constants which are used globally
10
10
 
11
- *************************************************************************************************************
12
11
  =end
13
12
 
14
13
  USER_CREATION_TIME_FORMAT = "%A, %d %B %Y" # user creation date format to be displayed
data/config/routes.rb CHANGED
@@ -2,23 +2,27 @@ Rails.application.routes.draw do
2
2
  devise_for :users , :controllers => {:registrations => "users"} do
3
3
 
4
4
  # giving mcms namespace /prefix
5
-
6
5
  get "mcms/users/login",:to => "devise/sessions#new"
7
6
  get "mcms/users/logout",:to => "devise/sessions#destroy"
8
7
  get "mcms/users",:to => "users#index"
9
8
  get "mcms/users/new",:to => "users#new"
10
9
  post "mcms/users", :to => "users#create"
10
+ post "mcms/users_first", :to => "users#first_user_create"
11
11
  get "mcms/users/edit/:id",:to => "users#edit"
12
12
  put "mcms/update_user",:to => "users#update"
13
13
  delete "mcms/destroy_user",:to => "users#destroy_user"
14
+ get "mcms/first_user", :to => "users#first_user"
14
15
 
15
16
  end
16
17
 
17
- resources :users, :controller => "users"
18
+ resources :users, :controller => "users", :except => [:create, :update]
18
19
 
19
20
  resources :roles ,:path => 'mcms/role' # with proper namespace/prefix
20
21
 
21
22
  match "mcms/roles",:to => "roles#index" # namespacing roles
22
23
 
24
+
25
+
23
26
  root :to => "home#index" # home page
24
27
  end
28
+
data/db/seeds.rb CHANGED
@@ -6,24 +6,6 @@
6
6
  # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
7
  # Mayor.create(name: 'Emanuel', city: cities.first)
8
8
  #writting seeds
9
- #puts "Enter admin user"
10
- #a = gets.chomp
11
-
12
- #puts "Enter password"
13
-
14
- #b = gets.chomp
15
-
16
- User.create!(:email => 'admin@mcms.com' ,:password => 'admin123' )
17
-
18
9
  Role.create!(:title => 'superuser')
19
10
 
20
-
21
- u = User.find_by_email('admin@mcms.com')
22
-
23
-
24
- r = Role.find_by_title('superuser')
25
-
26
-
27
- RolesUser.create!(:user_id => u.id , :role_id => r.id)
28
-
29
11