diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index b0af8b8a3895fff8f44761efa88c5e0f8335b775..bd0a27425ca0e46290197b0bf82cd2736e82762e 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -540,6 +540,9 @@ "Force_SSL": "Force SSL", "Force_SSL_Description": "*Caution!* _Force SSL_ should never be used with reverse proxy. If you have a reverse proxy, you should do the redirect THERE. This option exists for deployments like Heroku, that does not allow the redirect configuration at the reverse proxy.", "Forgot_password": "Forgot your password", + "Forgot_Password_Description": "You may use the following placeholders: <br /><ul><li>[Forgot_Password_Url] for the password recovery URL.</li><li>[name], [fname], [lname] for the user's full name, first name or last name, respectively.</li><li>[email] for the user's email.</li><li>[password] for the user's password.</li><li>[Site_Name] and [Site_URL] for the Application Name and URL respectively.</li></ul>", + "Forgot_Password_Email_Subject": "[Site_Name] - Password Recovery", + "Forgot_Password_Email": "Click <a href=\"[Forgot_Password_Url]\">here</a> to reset your password.", "Forward": "Forward", "Forward_chat": "Forward chat", "Forward_to_department": "Forward to department", diff --git a/packages/rocketchat-lib/server/startup/settings.coffee b/packages/rocketchat-lib/server/startup/settings.coffee index 899c7c7530af54f928ddd77ff23890c71142c462..651691a45e19291ed97e6407bb82cbb06589d25b 100644 --- a/packages/rocketchat-lib/server/startup/settings.coffee +++ b/packages/rocketchat-lib/server/startup/settings.coffee @@ -166,6 +166,10 @@ RocketChat.settings.addGroup 'Email', -> @add 'Accounts_UserAddedEmailSubject', '', { type: 'string', i18nLabel: "Subject", enableQuery: { _id: 'Accounts_UserAddedEmail_Customized', value: true }, i18nDefaultQuery: { _id: 'Accounts_UserAddedEmail_Customized', value: false } } @add 'Accounts_UserAddedEmail', '', { type: 'code', code: 'text/html', multiline: true, i18nLabel: 'Body', i18nDescription: 'Accounts_UserAddedEmail_Description', enableQuery: { _id: 'Accounts_UserAddedEmail_Customized', value: true }, i18nDefaultQuery: { _id: 'Accounts_UserAddedEmail_Customized', value: false } } + @section 'Forgot Password', -> + @add 'Forgot_Password_Customized', false, { type: 'boolean', i18nLabel: 'Custom' } + @add 'Forgot_Password_Email_Subject', '', { type: 'string', i18nLabel: 'Subject', enableQuery: { _id: 'Forgot_Password_Customized', value: true }, i18nDefaultQuery: { _id: 'Forgot_Password_Customized', value: false } } + @add 'Forgot_Password_Email', '', { type: 'code', code: 'text/html', multiline: true, i18nLabel: 'Body', i18nDescription: 'Forgot_Password_Description', enableQuery: { _id: 'Forgot_Password_Customized', value: true }, i18nDefaultQuery: { _id: 'Forgot_Password_Customized', value: false } } RocketChat.settings.addGroup 'Message', -> @add 'Message_AllowEditing', true, { type: 'boolean', public: true } diff --git a/server/methods/sendForgotPasswordEmail.coffee b/server/methods/sendForgotPasswordEmail.coffee index 0f81b0c1d9cf6e9b34cb55c54297ad7a65b9bdc1..68f2148a4e8d80e99b439695608ad8714a8da602 100644 --- a/server/methods/sendForgotPasswordEmail.coffee +++ b/server/methods/sendForgotPasswordEmail.coffee @@ -12,6 +12,14 @@ Meteor.methods email = _.find _.pluck(user.emails || [], 'address'), (userEmail) -> return regex.test(userEmail) + if RocketChat.settings.get('Forgot_Password_Customized') + subject = RocketChat.placeholders.replace(RocketChat.settings.get('Forgot_Password_Subject') || '') + html = RocketChat.placeholders.replace(RocketChat.settings.get('Forgot_Password_Email') || '') + Accounts.emailTemplates.resetPassword.subject = user -> + return subject + Accounts.emailTemplates.resetPassword.html = (user, url) -> + return html.replace('[Forgot_Password_Url]', url); + try Accounts.sendResetPasswordEmail(user._id, email) catch error