mcms_authentication 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/ajax-loader.gif +0 -0
- data/app/assets/javascripts/application.js +2 -2
- data/app/assets/javascripts/validate_login.js +37 -0
- data/app/assets/stylesheets/authentication_global.css +1542 -319
- data/app/controllers/application_controller.rb +5 -2
- data/app/controllers/home_controller.rb +18 -1
- data/app/controllers/roles_controller.rb +17 -10
- data/app/controllers/users_controller.rb +89 -36
- data/app/models/user.rb +9 -4
- data/app/views/roles/_form.html.erb +18 -13
- data/app/views/roles/index.html.erb +61 -32
- data/app/views/users/confirmations/new.html.erb +1 -0
- data/app/views/users/edit.html.erb +26 -14
- data/app/views/users/first_user.html.erb +99 -0
- data/app/views/users/index.html.erb +65 -38
- data/app/views/users/new.html.erb +24 -10
- data/app/views/users/passwords/edit.html.erb +17 -1
- data/app/views/users/passwords/new.html.erb +18 -2
- data/app/views/users/sessions/new.html.erb +22 -29
- data/app/views/users/unlocks/new.html.erb +6 -6
- data/config/initializers/constants.rb +5 -6
- data/config/routes.rb +6 -2
- data/db/seeds.rb +0 -18
- data/lib/generators/mcms_authentication/mcms_authentication_generator.rb +38 -13
- data/lib/generators/mcms_authentication/templates/models.rb +16 -34
- data/lib/mcms_authentication/engine.rb +32 -3
- metadata +5 -10
- data/app/assets/javascripts/authentication_global.js +0 -17
- data/app/assets/stylesheets/application.css +0 -33
- data/app/views/layouts/users/_javascript.html.erb +0 -3
- data/app/views/layouts/users/_stylesheet.html.erb +0 -3
- data/app/views/layouts/users/devise.html.erb +0 -40
- data/app/views/layouts/users/home.html.erb +0 -99
- data/lib/mcms_authentication/seeds.rb +0 -14
- data/lib/tasks/mcms_authentication_tasks.rake +0 -4
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
@Company Name :Mindfire Solutions Pvt. Ltd.
|
6
6
|
|
7
|
-
@Creator Name :Indranil Mukherjee
|
7
|
+
@Creator Name :Indranil Mukherjee
|
8
8
|
|
9
9
|
@Date Created :2012-06-04
|
10
10
|
|
@@ -30,7 +30,10 @@ class ApplicationController < ActionController::Base
|
|
30
30
|
|
31
31
|
flash[:error] = t(:access_denied,:default => "You are not authorized for doing this operation")
|
32
32
|
redirect_to root_url
|
33
|
-
|
33
|
+
|
34
34
|
end
|
35
35
|
|
36
|
+
|
37
|
+
|
36
38
|
end
|
39
|
+
|
@@ -30,8 +30,25 @@ class HomeController < ApplicationController
|
|
30
30
|
|
31
31
|
before_filter :authenticate_user!
|
32
32
|
|
33
|
-
layout HOME_LAYOUT
|
33
|
+
#layout HOME_LAYOUT
|
34
34
|
|
35
|
+
#layout HOME_LAYOUT
|
36
|
+
# layout "mcms/main_layout"
|
37
|
+
|
38
|
+
|
39
|
+
# check if mcms core layout exists
|
40
|
+
if Gem.available?('mcms')
|
41
|
+
|
42
|
+
#if yes then use core layout
|
43
|
+
layout "mcms/main_layout"
|
44
|
+
|
45
|
+
elsif Gem.available?('mcms_pages')# if not
|
46
|
+
|
47
|
+
# use page's default layout
|
48
|
+
layout "mcms_pages/layouts/mcms_layout"
|
49
|
+
|
50
|
+
end # end if
|
51
|
+
|
35
52
|
# @Params : No parameter
|
36
53
|
# @Returns : Nothing is returned
|
37
54
|
# @Purpose : Home page action
|
@@ -25,8 +25,23 @@ class RolesController < ApplicationController
|
|
25
25
|
|
26
26
|
load_and_authorize_resource # Need authorized users for each actions
|
27
27
|
|
28
|
-
layout HOME_LAYOUT # Following a particular layout.not default one
|
28
|
+
#layout HOME_LAYOUT # Following a particular layout.not default one
|
29
29
|
|
30
|
+
#layout "mcms/main_layout"
|
31
|
+
|
32
|
+
# check if mcms core layout exists
|
33
|
+
if Gem.available?('mcms')
|
34
|
+
|
35
|
+
#if yes then use core layout
|
36
|
+
layout "mcms/main_layout"
|
37
|
+
|
38
|
+
elsif Gem.available?('mcms_pages')# if not
|
39
|
+
|
40
|
+
# use page's default layout
|
41
|
+
layout "mcms_pages/layouts/mcms_layout"
|
42
|
+
|
43
|
+
end # end if
|
44
|
+
|
30
45
|
include Models # We need helps of a custom library which is defined in lib/mcms_authentication/models.rb
|
31
46
|
|
32
47
|
|
@@ -82,17 +97,9 @@ class RolesController < ApplicationController
|
|
82
97
|
@role = Role.new(params[:role])
|
83
98
|
|
84
99
|
# getting all plugins(modules) in current application
|
100
|
+
|
85
101
|
@all_plugins = get_all_plugins
|
86
102
|
|
87
|
-
|
88
|
-
# for i in 0..@all_plugins.length - 1
|
89
|
-
#
|
90
|
-
# if((@all_plugins[i]&@all_plugins[i+1]).any?)
|
91
|
-
# @all_plugins[i] = (@all_plugins[i] + @all_plugins[i+1]).uniq
|
92
|
-
# end
|
93
|
-
#
|
94
|
-
# end
|
95
|
-
|
96
103
|
respond_to do |format|
|
97
104
|
|
98
105
|
if @role.save # saving the role
|
@@ -19,36 +19,51 @@
|
|
19
19
|
class UsersController < Devise::RegistrationsController # inheriting Devise::Registrations controller to override the actions(CRUDS user)
|
20
20
|
|
21
21
|
|
22
|
-
prepend_before_filter :authenticate_user! # Obvious need of authetication before proceeding
|
22
|
+
prepend_before_filter :authenticate_user! , :except => ["first_user","first_user_create"] # Obvious need of authetication before proceeding
|
23
23
|
|
24
|
-
load_and_authorize_resource # authorized users are allowed for the operations
|
24
|
+
load_and_authorize_resource :except => ["first_user","first_user_create"] # authorized users are allowed for the operations
|
25
25
|
|
26
26
|
|
27
27
|
# The following line seems to be redundant as we already said that every action requires authentication.
|
28
|
-
# But its actually not.We need to override devise behaviour to sign up non-logged in user.Here it needs a logged in user
|
28
|
+
# But its actually not.We need to override devise behaviour to sign up non-logged in user.Here it needs a logged in user
|
29
29
|
prepend_before_filter :require_no_authentication, :except => [ :new,:index, :create,:edit,:destroy_user,:update ]
|
30
30
|
|
31
|
-
layout HOME_LAYOUT # using a layout
|
31
|
+
# layout HOME_LAYOUT # using a layout
|
32
|
+
# layout "mcms/main_layout"
|
32
33
|
|
34
|
+
# check if mcms core layout exists
|
35
|
+
if Gem.available?('mcms')
|
36
|
+
|
37
|
+
#if yes then use core layout
|
38
|
+
layout "mcms/main_layout"
|
39
|
+
|
40
|
+
elsif Gem.available?('mcms_pages')# if not
|
41
|
+
|
42
|
+
# use page's default layout
|
43
|
+
layout "mcms_pages/layouts/mcms_layout"
|
44
|
+
|
45
|
+
end # end if
|
46
|
+
|
47
|
+
|
33
48
|
# @Params : No parameter
|
34
49
|
# @Returns : Nothing is returned GET mcms/users
|
35
50
|
# @Purpose : Showing all existing users
|
36
|
-
|
51
|
+
|
37
52
|
def index
|
38
53
|
|
39
54
|
@users = User.all # Selecting all users
|
40
|
-
|
55
|
+
|
41
56
|
respond_to do |f|
|
42
57
|
|
43
58
|
f.html # HTML response
|
44
59
|
|
45
60
|
f.json {render :json => @users} # JSON response
|
46
|
-
|
61
|
+
|
47
62
|
end
|
48
|
-
|
63
|
+
|
49
64
|
end
|
50
65
|
|
51
|
-
|
66
|
+
|
52
67
|
# @Params : No parameter
|
53
68
|
# @Returns : Nothing is returned GET mcms/users/new
|
54
69
|
# @Purpose : Instantiating a new user
|
@@ -57,8 +72,10 @@ class UsersController < Devise::RegistrationsController # inheriting Devise::Re
|
|
57
72
|
|
58
73
|
@all_roles = Role.all # Roles needs to be there to select
|
59
74
|
|
60
|
-
|
75
|
+
@user = User.new #creating an instance of user
|
61
76
|
|
77
|
+
super # else is upto devise
|
78
|
+
|
62
79
|
end
|
63
80
|
|
64
81
|
|
@@ -67,14 +84,14 @@ class UsersController < Devise::RegistrationsController # inheriting Devise::Re
|
|
67
84
|
# @Purpose : Creating a new user
|
68
85
|
|
69
86
|
def create
|
70
|
-
|
87
|
+
|
71
88
|
build_resource # This helper is defined in devise which is building the resource (here user) so that we can have resource to be accessed here
|
72
89
|
|
73
90
|
|
74
91
|
@all_roles = Role.all # fetch all roles
|
75
92
|
|
76
93
|
if resource.save # saving the resource (here user)
|
77
|
-
|
94
|
+
|
78
95
|
if resource.active_for_authentication? # (we are not bother about active which is done after confirmation.In our case user is active upon registartion.No confirmation is needed. )
|
79
96
|
|
80
97
|
# saving the roles
|
@@ -82,15 +99,15 @@ class UsersController < Devise::RegistrationsController # inheriting Devise::Re
|
|
82
99
|
@all_roles.each do |role|
|
83
100
|
|
84
101
|
tmp = role.id.to_s + VALUE
|
85
|
-
|
86
|
-
|
102
|
+
|
103
|
+
|
87
104
|
|
88
105
|
RolesUser.create!(:user_id => resource.id , :role_id => Role.find_by_title(role.title).id) if params[tmp] == "1"
|
89
|
-
|
106
|
+
|
90
107
|
end
|
91
108
|
|
92
109
|
flash[:notice] = t(:user_create_success,:user_email => resource.email ,:default => "#{resource.email} successfully created")
|
93
|
-
|
110
|
+
|
94
111
|
redirect_to mcms_users_path
|
95
112
|
else
|
96
113
|
|
@@ -101,23 +118,23 @@ class UsersController < Devise::RegistrationsController # inheriting Devise::Re
|
|
101
118
|
RolesUser.create!(:user_id => resource.id , :role_id => Role.find_by_title(role.title).id) if params[tmp] == "1"
|
102
119
|
|
103
120
|
end
|
104
|
-
|
121
|
+
|
105
122
|
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
|
106
123
|
|
107
124
|
expire_session_data_after_sign_in!
|
108
125
|
|
109
126
|
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
|
110
|
-
|
127
|
+
|
111
128
|
end
|
112
|
-
|
129
|
+
|
113
130
|
else
|
114
|
-
|
131
|
+
|
115
132
|
clean_up_passwords resource
|
116
|
-
|
133
|
+
|
117
134
|
respond_with resource
|
118
|
-
|
135
|
+
|
119
136
|
end
|
120
|
-
|
137
|
+
|
121
138
|
end
|
122
139
|
|
123
140
|
# @Params : No parameter
|
@@ -125,16 +142,16 @@ class UsersController < Devise::RegistrationsController # inheriting Devise::Re
|
|
125
142
|
# @Purpose : Editing an existing user
|
126
143
|
|
127
144
|
def edit
|
128
|
-
|
145
|
+
|
129
146
|
@all_roles = Role.all
|
130
|
-
|
147
|
+
|
131
148
|
@user = User.find(params[:id]) # finding the user to be edited
|
132
|
-
|
149
|
+
|
133
150
|
respond_to do |f|
|
134
151
|
f.html #HTML response
|
135
152
|
f.json {render :json => @user} # JSON response
|
136
153
|
end
|
137
|
-
|
154
|
+
|
138
155
|
end
|
139
156
|
|
140
157
|
# @Params : No parameter
|
@@ -142,7 +159,7 @@ class UsersController < Devise::RegistrationsController # inheriting Devise::Re
|
|
142
159
|
# @Purpose : Updating an existing user
|
143
160
|
|
144
161
|
def update
|
145
|
-
|
162
|
+
|
146
163
|
@user = User.find(params[:id]) # Finding the user to be updated
|
147
164
|
|
148
165
|
@all_roles = Role.all
|
@@ -158,7 +175,7 @@ class UsersController < Devise::RegistrationsController # inheriting Devise::Re
|
|
158
175
|
if @user.update_attributes(params[:user])
|
159
176
|
|
160
177
|
# Assigning updated roles
|
161
|
-
|
178
|
+
|
162
179
|
@all_roles.each do |role|
|
163
180
|
|
164
181
|
tmp = role.id.to_s + VALUE
|
@@ -166,9 +183,9 @@ class UsersController < Devise::RegistrationsController # inheriting Devise::Re
|
|
166
183
|
RolesUser.create!(:user_id => resource.id , :role_id => Role.find_by_title(role.title).id) if params[tmp] == "1" && RolesUser.find_by_role_id_and_user_id(Role.find_by_title(role.title).id,resource.id).nil?
|
167
184
|
|
168
185
|
end
|
169
|
-
|
186
|
+
|
170
187
|
flash[:notice] = t(:user_update_success,:user_email => @user.email,:default => "#{@user.email} successfully updated")
|
171
|
-
|
188
|
+
|
172
189
|
redirect_to mcms_users_path
|
173
190
|
|
174
191
|
else
|
@@ -181,22 +198,58 @@ class UsersController < Devise::RegistrationsController # inheriting Devise::Re
|
|
181
198
|
end
|
182
199
|
|
183
200
|
# If the user needs to be destroyed
|
184
|
-
|
201
|
+
|
185
202
|
# @Params : No parameter
|
186
203
|
# @Returns : Nothing is returned DELETE mcms/users/1
|
187
204
|
# @Purpose : Destroying an existing user
|
188
205
|
|
189
206
|
def destroy_user
|
190
|
-
|
207
|
+
|
191
208
|
@user = User.find(params[:id]) # Find the user to be destroyed
|
192
|
-
|
209
|
+
|
193
210
|
@user.destroy # destroy it
|
194
211
|
|
195
212
|
flash[:notice] = t(:user_destroy_success,:user_email => @user.email,:default => "#{@user.email} successfully deleted")
|
196
213
|
|
197
|
-
redirect_to mcms_users_path #go to all users list
|
214
|
+
redirect_to mcms_users_path #go to all users list
|
215
|
+
|
216
|
+
end
|
217
|
+
|
218
|
+
def first_user
|
219
|
+
@user = User.new #creating an instance of user
|
220
|
+
unless User.all.empty?
|
221
|
+
redirect_to "/users/sign_in"
|
222
|
+
else
|
223
|
+
respond_to do |format|
|
224
|
+
format.html
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
198
228
|
|
199
229
|
end
|
200
230
|
|
201
|
-
|
231
|
+
def first_user_create
|
232
|
+
|
233
|
+
build_resource # This helper is defined in devise which is building the resource (here user) so that we can have resource to be accessed here
|
234
|
+
|
235
|
+
if resource.save # saving the resource (here user)
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
# saving the roles
|
240
|
+
|
241
|
+
RolesUser.create!(:user_id => resource.id , :role_id => Role.find_by_title("superuser").id)
|
242
|
+
|
243
|
+
|
244
|
+
flash[:notice] = t(:user_create_success,:user_email => resource.email ,:default => "#{resource.email} successfully created")
|
245
|
+
|
246
|
+
redirect_to mcms_users_path
|
247
|
+
else
|
248
|
+
clean_up_passwords resource
|
249
|
+
flash[:notice] = resource.errors.full_messages
|
250
|
+
redirect_to "/mcms/first_user"
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
202
254
|
end
|
255
|
+
|
data/app/models/user.rb
CHANGED
@@ -61,7 +61,7 @@ class User < ActiveRecord::Base
|
|
61
61
|
|
62
62
|
if self.roles.present?
|
63
63
|
|
64
|
-
|
64
|
+
self.roles.each do |role|
|
65
65
|
|
66
66
|
if role.title == role_title
|
67
67
|
|
@@ -73,7 +73,7 @@ class User < ActiveRecord::Base
|
|
73
73
|
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
end
|
77
77
|
|
78
78
|
else
|
79
79
|
|
@@ -82,8 +82,13 @@ class User < ActiveRecord::Base
|
|
82
82
|
end
|
83
83
|
|
84
84
|
end
|
85
|
-
|
86
|
-
|
85
|
+
|
86
|
+
# @Params : String
|
87
|
+
# @Returns : String
|
88
|
+
# @Purpose : returns the full name of user
|
89
|
+
def full_name
|
90
|
+
return sprintf"%s %s", first_name, last_name
|
91
|
+
end
|
87
92
|
|
88
93
|
|
89
94
|
|
@@ -17,8 +17,13 @@
|
|
17
17
|
-->
|
18
18
|
|
19
19
|
<!-- This line of code is responsible for javascript to be loaded for this particular page -->
|
20
|
+
<% content_for :head do %>
|
20
21
|
|
21
|
-
|
22
|
+
<%= javascript_include_tag "application","authentication_global" %>
|
23
|
+
<%= stylesheet_link_tag "authentication_global",:media => "all" %>
|
24
|
+
<%= render(:partial => "form.js",:locals => {:all_plugins => all_plugins}) %>
|
25
|
+
|
26
|
+
<% end %>
|
22
27
|
|
23
28
|
|
24
29
|
<!-- form for creating a new role -->
|
@@ -55,27 +60,27 @@
|
|
55
60
|
|
56
61
|
<%= f.text_field :title %></div>
|
57
62
|
|
58
|
-
<div id="records">
|
63
|
+
<div id="records" style="width:100%;margin-top: 30px;">
|
59
64
|
|
60
65
|
<% i = 1 %>
|
61
66
|
|
62
67
|
<% all_plugins.each do |p| %>
|
68
|
+
|
69
|
+
<div style="margin-top: 10px;border-bottom: 1px solid #ccc; padding-bottom: 10px;" > <!-- Showing all plugins alternative css applied -->
|
63
70
|
|
64
|
-
<div
|
65
|
-
|
66
|
-
<span class="title">
|
71
|
+
<div style="float: left">
|
67
72
|
|
68
|
-
<
|
73
|
+
<div>
|
69
74
|
|
70
75
|
<strong> <%= Models.get_module_name(p).classify %></strong> <!-- module -->
|
71
76
|
|
72
|
-
</
|
77
|
+
</div>
|
73
78
|
|
74
|
-
</
|
79
|
+
</div>
|
75
80
|
|
76
81
|
<!-- Access control user input of above module -->
|
77
82
|
|
78
|
-
<
|
83
|
+
<div style="float: right;">
|
79
84
|
|
80
85
|
<% r = Plugin.find_by_role_module_and_role_id(p.last,@role.id) %>
|
81
86
|
|
@@ -212,8 +217,8 @@
|
|
212
217
|
<%= hidden_field_tag "#{p.last}_all" %>
|
213
218
|
<% end %>
|
214
219
|
<% end %>
|
215
|
-
</
|
216
|
-
|
220
|
+
</div>
|
221
|
+
<div style="clear: both"></div>
|
217
222
|
</div>
|
218
223
|
|
219
224
|
<% i = i+1 %>
|
@@ -221,8 +226,8 @@
|
|
221
226
|
<% end %>
|
222
227
|
|
223
228
|
</div>
|
224
|
-
|
225
|
-
<div class="form-actions"
|
229
|
+
<div style="clear: both"></div>
|
230
|
+
<div class="form-actions">
|
226
231
|
|
227
232
|
<div class="form-actions-left">
|
228
233
|
|
@@ -16,58 +16,87 @@
|
|
16
16
|
|
17
17
|
-->
|
18
18
|
|
19
|
-
<div id="main-content">
|
20
19
|
|
21
|
-
|
20
|
+
<% content_for :head do %>
|
22
21
|
|
23
|
-
|
22
|
+
<%= javascript_include_tag "application","authentication_global" %>
|
23
|
+
<%= stylesheet_link_tag "authentication_global",:media => "all" %>
|
24
24
|
|
25
|
-
|
25
|
+
<% end %>
|
26
26
|
|
27
|
-
|
27
|
+
<div class="news">
|
28
28
|
|
29
|
-
<%= image_tag "/assets/icons/add.png" %>
|
30
29
|
|
31
|
-
|
30
|
+
<% @roles.each do |role| %>
|
31
|
+
<div class="alert "><div class="body"><span class="mini-icon mini-icon-issue-comment"></span>
|
32
32
|
|
33
|
-
|
33
|
+
<div class="title" style="float: left;">
|
34
|
+
<a href="#"><%= role.title %></a>
|
35
|
+
<span> was added </span> about
|
34
36
|
|
35
|
-
|
37
|
+
<time class="js-relative-date"><%= distance_of_time_in_words(role.created_at,Time.now) %> ago</time>
|
38
|
+
</div>
|
36
39
|
|
37
|
-
|
40
|
+
<!-- Super user should not be deleted -->
|
41
|
+
<div style="float: right;">
|
42
|
+
|
43
|
+
<% unless role.title == "superuser" %>
|
44
|
+
<%= 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 %>
|
38
45
|
|
39
|
-
|
46
|
+
<%= link_to image_tag("/assets/icons/application_edit.png" ,:alt=> "User_edit" ,:height => "16 px" ,:width => "16 px;"), edit_role_path(role) %>
|
47
|
+
<% end %>
|
48
|
+
|
49
|
+
</div>
|
40
50
|
|
41
|
-
|
51
|
+
<div style="clear: both"></div>
|
42
52
|
|
43
|
-
|
53
|
+
</div></div>
|
54
|
+
<% end %>
|
44
55
|
|
45
|
-
<div class="clearfix record <%= cycle("odd", "even") %>" > <!-- alternative div css change -->
|
46
56
|
|
47
|
-
|
57
|
+
</div>
|
48
58
|
|
49
|
-
<span class="preview">
|
50
59
|
|
51
|
-
<strong> <%= role.title %></strong>
|
52
60
|
|
53
|
-
</span>
|
54
61
|
|
55
|
-
|
62
|
+
<div id="your-repos" class="repos">
|
63
|
+
<div class="top-bar">
|
64
|
+
<h2>Quick tasks </h2>
|
65
|
+
<a class="button new-repo" href="<%= new_role_path %>">Add new role</a>
|
66
|
+
</div>
|
56
67
|
|
57
|
-
|
58
|
-
|
59
|
-
|
68
|
+
<ul class="repo-list" >
|
69
|
+
|
70
|
+
<li class="public source">
|
71
|
+
<a href="/mcms/roles/">
|
72
|
+
<span class="mini-icon "></span>
|
73
|
+
<span class="owner">Roles</span><span class="repo"></span>
|
74
|
+
<span class="arrow"></span>
|
75
|
+
</a>
|
76
|
+
</li>
|
77
|
+
|
78
|
+
<li class="public source">
|
79
|
+
<a href="/mcms/users/new">
|
80
|
+
<span class="mini-icon "></span>
|
81
|
+
<span class="owner">New User</span> <span class="repo"></span>
|
82
|
+
<span class="arrow"></span>
|
83
|
+
</a>
|
84
|
+
</li>
|
85
|
+
|
86
|
+
<li class="public source">
|
87
|
+
<a href="/mcms/role/new">
|
88
|
+
<span class="mini-icon "></span>
|
89
|
+
<span class="owner">Add new role</span><span class="repo"></span>
|
90
|
+
<span class="arrow"></span>
|
91
|
+
</a>
|
92
|
+
</li>
|
93
|
+
|
94
|
+
</ul>
|
95
|
+
<div class="bottom-bar">
|
96
|
+
</div>
|
97
|
+
</div>
|
60
98
|
|
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
99
|
|
65
|
-
</div>
|
66
|
-
|
67
|
-
<% end %>
|
68
100
|
|
69
|
-
</div>
|
70
|
-
|
71
|
-
</div>
|
72
101
|
|
73
|
-
<!-- End of listing -->
|
102
|
+
<!-- End of user listing -->
|
@@ -17,8 +17,15 @@
|
|
17
17
|
-->
|
18
18
|
|
19
19
|
<!-- This line of code is responsible for javascript to be loaded for this particular page -->
|
20
|
+
<% content_for :head do %>
|
21
|
+
|
22
|
+
<%= javascript_include_tag "application","authentication_global" %>
|
23
|
+
<%= stylesheet_link_tag "authentication_global",:media => "all" %>
|
24
|
+
<%= render(:partial => "role.js",:locals => {:all_roles => @all_roles}) %>
|
25
|
+
|
26
|
+
<% end %>
|
27
|
+
|
20
28
|
|
21
|
-
<% content_for :javascript, render(:partial => "role.js",:locals => {:all_roles => @all_roles}) %>
|
22
29
|
|
23
30
|
<!-- Editing an existing user -->
|
24
31
|
|
@@ -34,37 +41,37 @@
|
|
34
41
|
|
35
42
|
<%= devise_error_messages! %>
|
36
43
|
|
37
|
-
<div class="field
|
44
|
+
<div class="field "><%= f.label :email %><br />
|
38
45
|
|
39
46
|
<%= f.email_field :email %>
|
40
47
|
|
41
48
|
</div>
|
42
49
|
|
43
|
-
<div class="field
|
50
|
+
<div class="field "><%= f.label :first_name %><br />
|
44
51
|
|
45
52
|
<%= f.text_field :first_name %>
|
46
53
|
|
47
54
|
</div>
|
48
55
|
|
49
|
-
<div class="field
|
56
|
+
<div class="field "><%= f.label :last_name %><br />
|
50
57
|
|
51
58
|
<%= f.text_field :last_name %>
|
52
59
|
|
53
60
|
</div>
|
54
|
-
<div class="field
|
61
|
+
<div class="field "><%= f.label :password %><br/> <i>(leave blank if you don't want to change it)</i>
|
55
62
|
|
56
63
|
<br /> <br />
|
57
64
|
|
58
65
|
<%= f.password_field :password, :autocomplete => "off" %></div>
|
59
66
|
|
60
|
-
<div class="field
|
67
|
+
<div class="field "><%= f.label :password_confirmation %>
|
61
68
|
|
62
69
|
<br />
|
63
70
|
|
64
71
|
<%= f.password_field :password_confirmation %></div>
|
65
72
|
|
66
73
|
|
67
|
-
<div class="field
|
74
|
+
<div class="field ">
|
68
75
|
|
69
76
|
<span class="label-with-help">
|
70
77
|
|
@@ -77,10 +84,15 @@
|
|
77
84
|
<% @all_roles.each do |role| %>
|
78
85
|
|
79
86
|
<li>
|
80
|
-
<% if
|
81
|
-
|
82
|
-
|
83
|
-
|
87
|
+
<% if @user.roles.present? %>
|
88
|
+
<% if(@user.roles.first.title == role.title) %>
|
89
|
+
|
90
|
+
<%= check_box_tag "#{role.id}" , "1" ,:checked => "checked" %>
|
91
|
+
<%= hidden_field_tag "#{role.id}_value","1" %>
|
92
|
+
<% else %>
|
93
|
+
<%= check_box_tag "#{role.id}" %>
|
94
|
+
<%= hidden_field_tag "#{role.id}_value" %>
|
95
|
+
<% end %>
|
84
96
|
<% else %>
|
85
97
|
<%= check_box_tag "#{role.id}" %>
|
86
98
|
<%= hidden_field_tag "#{role.id}_value" %>
|
@@ -100,9 +112,9 @@
|
|
100
112
|
|
101
113
|
<%= hidden_field_tag "id",@user.id %>
|
102
114
|
|
103
|
-
<div class="form-actions"
|
115
|
+
<div class="form-actions">
|
104
116
|
|
105
|
-
<div class="form-actions-left"
|
117
|
+
<div class="form-actions-left">
|
106
118
|
|
107
119
|
<%= f.submit "Save",:class => "button" %>
|
108
120
|
|
@@ -110,7 +122,7 @@
|
|
110
122
|
|
111
123
|
</div>
|
112
124
|
|
113
|
-
<div class="form-actions-right" >
|
125
|
+
<div class="form-actions-right" style="float: right;margin-right: 10px;margin-top: 8px;" >
|
114
126
|
|
115
127
|
<% unless @user.has_role? "superuser" %><!-- Superuser should not be deleted any way -->
|
116
128
|
|