Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
56398ea1
Commit
56398ea1
authored
Jul 15, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not sent a generated password via email for admin created user.
parent
275a5281
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
18 deletions
+17
-18
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+1
-0
app/mailers/emails/profile.rb
app/mailers/emails/profile.rb
+2
-1
app/models/user.rb
app/models/user.rb
+10
-1
app/services/notification_service.rb
app/services/notification_service.rb
+2
-2
app/views/notify/new_user_email.html.haml
app/views/notify/new_user_email.html.haml
+1
-8
app/views/notify/new_user_email.text.erb
app/views/notify/new_user_email.text.erb
+1
-6
No files found.
app/controllers/admin/users_controller.rb
View file @
56398ea1
...
...
@@ -45,6 +45,7 @@ class Admin::UsersController < Admin::ApplicationController
@user
=
User
.
new
(
user_params
.
merge
(
opts
))
@user
.
created_by_id
=
current_user
.
id
@user
.
generate_password
@user
.
generate_reset_token
@user
.
skip_confirmation!
respond_to
do
|
format
|
...
...
app/mailers/emails/profile.rb
View file @
56398ea1
module
Emails
module
Profile
def
new_user_email
(
user_id
,
password
)
def
new_user_email
(
user_id
,
password
,
token
)
@user
=
User
.
find
(
user_id
)
@password
=
password
@target_url
=
user_url
(
@user
)
@token
=
token
mail
(
to:
@user
.
email
,
subject:
subject
(
"Account was created for you"
))
end
...
...
app/models/user.rb
View file @
56398ea1
...
...
@@ -240,6 +240,15 @@ class User < ActiveRecord::Base
end
end
def
generate_reset_token
@token
,
enc
=
Devise
.
token_generator
.
generate
(
self
.
class
,
:reset_password_token
)
self
.
reset_password_token
=
enc
self
.
reset_password_sent_at
=
Time
.
now
.
utc
@token
end
def
namespace_uniq
namespace_name
=
self
.
username
if
Namespace
.
find_by
(
path:
namespace_name
)
...
...
@@ -488,7 +497,7 @@ class User < ActiveRecord::Base
def
post_create_hook
log_info
(
"User
\"
#{
self
.
name
}
\"
(
#{
self
.
email
}
) was created"
)
notification_service
.
new_user
(
self
)
notification_service
.
new_user
(
self
,
@token
)
system_hook_service
.
execute_hooks_for
(
self
,
:create
)
end
...
...
app/services/notification_service.rb
View file @
56398ea1
...
...
@@ -105,9 +105,9 @@ class NotificationService
end
# Notify new user with email after creation
def
new_user
(
user
)
def
new_user
(
user
,
token
=
nil
)
# Don't email omniauth created users
mailer
.
new_user_email
(
user
.
id
,
user
.
password
)
unless
user
.
extern_uid?
mailer
.
new_user_email
(
user
.
id
,
user
.
password
,
token
)
unless
user
.
extern_uid?
end
# Notify users on new note in system
...
...
app/views/notify/new_user_email.html.haml
View file @
56398ea1
...
...
@@ -11,11 +11,4 @@
-
if
@user
.
created_by_id
%p
password..................................
%code
=
@password
%p
You will be forced to change this password immediately after login.
%p
=
link_to
"Click here to login"
,
root_url
=
link_to
"Click here to set your password"
,
edit_password_url
(
@user
,
:reset_password_token
=>
@token
)
app/views/notify/new_user_email.text.erb
View file @
56398ea1
...
...
@@ -4,10 +4,5 @@ The Administrator created an account for you. Now you are a member of the compan
login..................
<%=
@user
.
email
%>
<%
if
@user
.
created_by_id
%>
password...............
<%=
@password
%>
You will be forced to change this password immediately after login.
<%=
link_to
"Click here to set your password"
,
edit_password_url
(
@user
,
:reset_password_token
=>
@token
)
%>
<%
end
%>
Click here to login:
<%=
url_for
(
root_url
)
%>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment