diff --git a/packages/rocketchat-lib/i18n/en.i18n.json b/packages/rocketchat-lib/i18n/en.i18n.json
index 61c754de6b64..bc6bbaedc396 100644
--- a/packages/rocketchat-lib/i18n/en.i18n.json
+++ b/packages/rocketchat-lib/i18n/en.i18n.json
@@ -99,6 +99,8 @@
"Accounts_ShowFormLogin" : "Show form-based Login",
"Accounts_UseDefaultBlockedDomainsList" : "Use Default Blocked Domains List",
"Accounts_UseDNSDomainCheck" : "Use DNS Domain Check",
+ "Accounts_UserAddedEmail_Subject" : "User Added Welcome Email",
+ "Accounts_UserAddedEmail_Description" : "You may use the following placeholders:
- [name], [fname], [lname] for the user's full name, first name or last name, respectively.
- [email] for the user's email.
- [password] for the user's password.
- [Site_Name] and [Site_URL] for the Application Name and URL respectively.
",
"Activate" : "Activate",
"Activity" : "Activity",
"Add" : "Add",
@@ -475,6 +477,7 @@
"italics" : "italics",
"join" : "Join",
"Join_audio_call" : "Join audio call",
+ "Join_default_channels" : "Join default channels",
"Join_the_Community" : "Join the Community",
"Join_the_given_channel" : "Join the given channel",
"Join_video_call" : "Join video call",
@@ -783,6 +786,7 @@
"Query_description" : "Additional conditions for determining which users to send the email to. Unsubscribed users are automatically removed from the query. It must be a valid JSON. Example: \"{\"createdAt\":{\"$gt\":{\"$date\": \"2015-01-01T00:00:00.000Z\"}}}\"",
"Quick_Search" : "Quick Search",
"quote" : "quote",
+ "Random" : "Random",
"Reactions" : "Reactions",
"Recents" : "Recents",
"Record" : "Record",
@@ -878,6 +882,7 @@
"Send_invitation_email_success" : "You have successfully sent an invitation email to the following addresses:",
"Send_invitation_email_warning" : "In order to send invitation emails, you must first configure SMTP settings.",
"Send_Message" : "Send Message",
+ "Send_welcome_email" : "Send welcome email",
"Send_your_JSON_payloads_to_this_URL" : "Send your JSON payloads to this URL.",
"Sending" : "Sending...",
"Service" : "Service",
@@ -1084,6 +1089,7 @@
"UTF8_Names_Validation" : "UTF8 Names Validation",
"UTF8_Names_Validation_Description" : "Do not allow special characters and spaces. You can use - _ and . but not at the end of the name",
"Verification_email_sent" : "Verification email sent",
+ "Verified" : "Verified",
"View_All" : "View All",
"View_Logs" : "View Logs",
"Viewing_room_administration" : "Viewing room administration",
@@ -1137,4 +1143,4 @@
"Your_Open_Source_solution" : "Your own Open Source chat solution",
"Your_password_is_wrong" : "Your password is wrong!",
"Your_push_was_sent_to_s_devices" : "Your push was sent to %s devices"
-}
\ No newline at end of file
+}
diff --git a/packages/rocketchat-lib/server/methods/insertOrUpdateUser.coffee b/packages/rocketchat-lib/server/methods/insertOrUpdateUser.coffee
index f74f40d1c21c..84eafffc4b80 100644
--- a/packages/rocketchat-lib/server/methods/insertOrUpdateUser.coffee
+++ b/packages/rocketchat-lib/server/methods/insertOrUpdateUser.coffee
@@ -26,7 +26,7 @@ Meteor.methods
nameValidation = new RegExp '^[0-9a-zA-Z-_.]+$'
if not nameValidation.test userData.username
- throw new Meteor.Error 'error-input-is-not-a-valid-field', "#{username} is not a valid username", { method: 'insertOrUpdateUser', input: username, field: 'Username' }
+ throw new Meteor.Error 'error-input-is-not-a-valid-field', "#{userData.username} is not a valid username", { method: 'insertOrUpdateUser', input: userData.username, field: 'Username' }
if not userData._id and not userData.password
throw new Meteor.Error 'error-the-field-is-required', 'The field Password is required', { method: 'insertOrUpdateUser', field: 'Password' }
@@ -54,12 +54,49 @@ Meteor.methods
if userData.requirePasswordChange
updateUser.$set.requirePasswordChange = userData.requirePasswordChange
+ if userData.verified
+ updateUser.$set['emails.0.verified'] = true
+
Meteor.users.update { _id: _id }, updateUser
+ if userData.joinDefaultChannels
+ Meteor.runAsUser _id, ->
+ Meteor.call('joinDefaultChannels');
+
+ if userData.sendWelcomeEmail
+ html = RocketChat.settings.get('Accounts_UserAddedEmail');
+ html = html.replace /\[name\]/g, userData.name or ''
+ html = html.replace /\[fname\]/g, _.strLeft(userData.name, ' ') or ''
+ html = html.replace /\[lname\]/g, _.strRightBack(userData.name, ' ') or ''
+ html = html.replace /\[email\]/g, userData.email or ''
+ html = html.replace /\[password\]/g, userData.password or ''
+ html = html.replace /\[Site_Name\]/g, RocketChat.settings.get("Site_Name") or ''
+ html = html.replace /\[Site_URL\]/g, RocketChat.settings.get("Site_Url") or ''
+
+ email = {
+ to: userData.email
+ from: RocketChat.settings.get('From_Email'),
+ subject: RocketChat.settings.get('Accounts_UserAddedEmail_Subject') || TAPi18n.__("Welcome_to_the", { lng: RocketChat.settings.get('Language') || "en" }) + (RocketChat.settings.get('Site_Name') || ""),
+ html: html
+ };
+
+ Email.send(email);
+
return _id
else
#update user
- Meteor.users.update { _id: userData._id }, { $set: { name: userData.name, requirePasswordChange: userData.requirePasswordChange } }
+ updateUser = {
+ $set: {
+ name: userData.name,
+ requirePasswordChange: userData.requirePasswordChange
+ }
+ }
+ if userData.verified
+ updateUser.$set['emails.0.verified'] = true
+ else
+ updateUser.$set['emails.0.verified'] = false
+
+ Meteor.users.update { _id: userData._id }, updateUser
RocketChat.setUsername userData._id, userData.username
RocketChat.setEmail userData._id, userData.email
diff --git a/packages/rocketchat-lib/server/startup/settings.coffee b/packages/rocketchat-lib/server/startup/settings.coffee
index c4e39803bf74..b3ba1f01865e 100644
--- a/packages/rocketchat-lib/server/startup/settings.coffee
+++ b/packages/rocketchat-lib/server/startup/settings.coffee
@@ -117,6 +117,10 @@ RocketChat.settings.addGroup 'SMTP', ->
@add 'Invitation_HTML', 'You have been invited to Rocket.Chat
Go to ' + __meteor_runtime_config__?.ROOT_URL + ' and try the best open source chat solution available today!
', { type: 'string', multiline: true }
@add 'Accounts_Enrollment_Email', '', { type: 'string', multiline: true }
+ @section 'Registration via Admin', ->
+ @add 'Accounts_UserAddedEmail', '', { type: 'string', multiline: true, i18nLabel: 'E-mail', i18nDescription: 'Accounts_UserAddedEmail_Description' }
+ @add 'Accounts_UserAddedEmailSubject', '', { type: 'string', i18nLabel: "Subject" }
+
RocketChat.settings.addGroup 'Message', ->
@add 'Message_AllowEditing', true, { type: 'boolean', public: true }
diff --git a/packages/rocketchat-theme/assets/stylesheets/base.less b/packages/rocketchat-theme/assets/stylesheets/base.less
index 79323a2bfc05..5dec0f1e5b8e 100644
--- a/packages/rocketchat-theme/assets/stylesheets/base.less
+++ b/packages/rocketchat-theme/assets/stylesheets/base.less
@@ -3238,6 +3238,10 @@ body:not(.is-cordova) {
}
> .input-line {
margin-top: 20px;
+
+ #password {
+ width: 70%;
+ }
}
nav {
padding: 0;
diff --git a/packages/rocketchat-ui-flextab/flex-tab/tabs/userEdit.coffee b/packages/rocketchat-ui-flextab/flex-tab/tabs/userEdit.coffee
index 2f9afcdd8de3..3c5a7456c537 100644
--- a/packages/rocketchat-ui-flextab/flex-tab/tabs/userEdit.coffee
+++ b/packages/rocketchat-ui-flextab/flex-tab/tabs/userEdit.coffee
@@ -5,12 +5,20 @@ Template.userEdit.helpers
user: ->
return Template.instance().user
+ requirePasswordChange: ->
+ return !Template.instance().user || Template.instance().user.requirePasswordChange
+
Template.userEdit.events
'click .cancel': (e, t) ->
e.stopPropagation()
e.preventDefault()
t.cancel(t.find('form'))
+ 'click #randomPassword': (e, t) ->
+ e.stopPropagation()
+ e.preventDefault()
+ $('#password').val(Random.id())
+
'submit form': (e, t) ->
e.stopPropagation()
e.preventDefault()
@@ -22,6 +30,7 @@ Template.userEdit.onCreated ->
@cancel = (form, username) =>
form.reset()
+ this.$('input[type=checkbox]').prop('checked', true);
if @user
@data.back(username)
else
@@ -32,8 +41,11 @@ Template.userEdit.onCreated ->
userData.name = s.trim(this.$("#name").val())
userData.username = s.trim(this.$("#username").val())
userData.email = s.trim(this.$("#email").val())
+ userData.verified = this.$("#verified:checked").length > 0
userData.password = s.trim(this.$("#password").val())
userData.requirePasswordChange = this.$("#changePassword:checked").length > 0
+ userData.joinDefaultChannels = this.$("#joinDefaultChannels:checked").length > 0
+ userData.sendWelcomeEmail = this.$("#sendWelcomeEmail:checked").length > 0
return userData
@validate = =>
diff --git a/packages/rocketchat-ui-flextab/flex-tab/tabs/userEdit.html b/packages/rocketchat-ui-flextab/flex-tab/tabs/userEdit.html
index edf6e5704ca1..793b4ef8ccb6 100644
--- a/packages/rocketchat-ui-flextab/flex-tab/tabs/userEdit.html
+++ b/packages/rocketchat-ui-flextab/flex-tab/tabs/userEdit.html
@@ -3,7 +3,7 @@
{{_ "You_are_not_authorized_to_view_this_page"}}
{{else}}
-
- {{#if hasPermission 'edit-other-user-password'}}
-
-
-
-
-
+ {{#if hasPermission 'edit-other-user-password'}}
+
+ {{_ "Password"}}
+
+
+
+
+
+
+ {{_ "Require_password_change"}}
+
+
{{/if}}
+ {{#unless user}}
+
+
+
+ {{_ "Join_default_channels"}}
+
+
+
+
+
+ {{_ "Send_welcome_email"}}
+
+
+ {{/unless}}