mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
commit
ecc8c96c03
@ -56,8 +56,7 @@ var InviteNewUserController = Ember.Controller.extend({
|
||||
// but the user's status in the response object will be 'invited-pending'.
|
||||
if (newUser.get('status') === 'invited-pending') {
|
||||
self.notifications.showWarn('Invitation email was not sent. Please try resending.');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
self.notifications.showSuccess(notificationText, false);
|
||||
}
|
||||
}).catch(function (errors) {
|
||||
|
@ -66,10 +66,16 @@ var SettingsUserController = Ember.ObjectController.extend({
|
||||
resend: function () {
|
||||
var self = this;
|
||||
|
||||
this.get('model').resendInvite().then(function () {
|
||||
self.get('model').set('status', 'invited');
|
||||
this.get('model').resendInvite().then(function (result) {
|
||||
var notificationText = 'Invitation resent! (' + self.get('email') + ')';
|
||||
self.notifications.showSuccess(notificationText, false);
|
||||
// If sending the invitation email fails, the API will still return a status of 201
|
||||
// but the user's status in the response object will be 'invited-pending'.
|
||||
if (result.users[0].status === 'invited-pending') {
|
||||
self.notifications.showWarn('Invitation email was not sent. Please try resending.');
|
||||
} else {
|
||||
self.get('model').set('status', result.users[0].status);
|
||||
self.notifications.showSuccess(notificationText, false);
|
||||
}
|
||||
}).catch(function (error) {
|
||||
self.notifications.closePassive();
|
||||
self.notifications.showAPIError(error);
|
||||
|
@ -1,14 +1,14 @@
|
||||
// # Mail API
|
||||
// API for sending Mail
|
||||
var when = require('when'),
|
||||
_ = require('lodash'),
|
||||
config = require('../config'),
|
||||
canThis = require('../permissions').canThis,
|
||||
errors = require('../errors'),
|
||||
path = require('path'),
|
||||
fs = require('fs'),
|
||||
templatesDir = path.resolve(__dirname, '..', 'email-templates'),
|
||||
htmlToText = require('html-to-text'),
|
||||
var _ = require('lodash'),
|
||||
when = require('when'),
|
||||
config = require('../config'),
|
||||
canThis = require('../permissions').canThis,
|
||||
errors = require('../errors'),
|
||||
path = require('path'),
|
||||
fs = require('fs'),
|
||||
templatesDir = path.resolve(__dirname, '..', 'email-templates'),
|
||||
htmlToText = require('html-to-text'),
|
||||
mail;
|
||||
|
||||
/**
|
||||
@ -105,9 +105,10 @@ mail = {
|
||||
//generate a plain-text version of the same email
|
||||
textContent = htmlToText.fromString(htmlContent);
|
||||
|
||||
resolve({ html: htmlContent,
|
||||
text: textContent
|
||||
});
|
||||
resolve({
|
||||
html: htmlContent,
|
||||
text: textContent
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -132,7 +132,8 @@ users = {
|
||||
add: function add(object, options) {
|
||||
var newUser,
|
||||
user,
|
||||
roleId;
|
||||
roleId,
|
||||
emailData;
|
||||
|
||||
return canThis(options.context).add.user(object).then(function () {
|
||||
return utils.checkObject(object, docName).then(function (checkedUserData) {
|
||||
@ -182,39 +183,41 @@ users = {
|
||||
dbHash = response.settings[0].value;
|
||||
return dataProvider.User.generateResetToken(user.email, expires, dbHash);
|
||||
}).then(function (resetToken) {
|
||||
when.join(users.read({'id': user.created_by}), settings.read({'key': 'title'})).then(function (values) {
|
||||
return when.join(users.read({'id': user.created_by}), settings.read({'key': 'title'})).then(function (values) {
|
||||
var invitedBy = values[0].users[0],
|
||||
blogTitle = values[1].settings[0].value,
|
||||
baseUrl = config.forceAdminSSL ? (config.urlSSL || config.url) : config.url,
|
||||
resetUrl = baseUrl.replace(/\/$/, '') + '/ghost/signup/' + resetToken + '/',
|
||||
emailData = {
|
||||
blogName: blogTitle,
|
||||
invitedByName: invitedBy.name,
|
||||
invitedByEmail: invitedBy.email,
|
||||
resetLink: resetUrl
|
||||
};
|
||||
resetUrl = baseUrl.replace(/\/$/, '') + '/ghost/signup/' + resetToken + '/';
|
||||
|
||||
mail.generateContent({data: emailData, template: 'invite-user'}).then(function (emailContent) {
|
||||
emailData = {
|
||||
blogName: blogTitle,
|
||||
invitedByName: invitedBy.name,
|
||||
invitedByEmail: invitedBy.email,
|
||||
resetLink: resetUrl
|
||||
};
|
||||
|
||||
var payload = {
|
||||
mail: [
|
||||
{
|
||||
message: {
|
||||
to: user.email,
|
||||
subject: emailData.invitedByName + ' has invited you to join ' + emailData.blogName,
|
||||
html: emailContent.html,
|
||||
text: emailContent.text
|
||||
},
|
||||
options: {}
|
||||
}
|
||||
]
|
||||
};
|
||||
return mail.send(payload, {context: {internal: true}}).then(function () {
|
||||
// If status was invited-pending and sending the invitation succeeded, set status to invited.
|
||||
if (user.status === 'invited-pending') {
|
||||
return dataProvider.User.edit({status: 'invited'}, {id: user.id});
|
||||
return mail.generateContent({data: emailData, template: 'invite-user'});
|
||||
}).then(function (emailContent) {
|
||||
var payload = {
|
||||
mail: [
|
||||
{
|
||||
message: {
|
||||
to: user.email,
|
||||
subject: emailData.invitedByName + ' has invited you to join ' + emailData.blogName,
|
||||
html: emailContent.html,
|
||||
text: emailContent.text
|
||||
},
|
||||
options: {}
|
||||
}
|
||||
});
|
||||
]
|
||||
};
|
||||
return mail.send(payload, {context: {internal: true}}).then(function () {
|
||||
// If status was invited-pending and sending the invitation succeeded, set status to invited.
|
||||
if (user.status === 'invited-pending') {
|
||||
return dataProvider.User.edit({status: 'invited'}, {id: user.id}).then(function (editedUser) {
|
||||
user = editedUser.toJSON();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}).then(function () {
|
||||
|
Loading…
Reference in New Issue
Block a user