0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Merge pull request #3260 from sebgie/invited-pending

Add status invited-pending for users
This commit is contained in:
Hannah Wolfe 2014-07-14 11:14:13 +01:00
commit e20c773e5d
2 changed files with 11 additions and 4 deletions

View file

@ -198,8 +198,6 @@ authentication = {
}).then(function () { }).then(function () {
return when.resolve({ users: [setupUser]}); return when.resolve({ users: [setupUser]});
}).otherwise(function (error) { }).otherwise(function (error) {
console.log('error');
console.log(error);
return when.reject(new errors.UnauthorizedError(error.message)); return when.reject(new errors.UnauthorizedError(error.message));
}); });
} }

View file

@ -161,7 +161,7 @@ users = {
return dataProvider.User.add(newUser, options); return dataProvider.User.add(newUser, options);
} else { } else {
// only invitations for already invited users are resent // only invitations for already invited users are resent
if (foundUser.toJSON().status === 'invited') { if (foundUser.get('status') === 'invited' || foundUser.get('status') === 'invited-pending') {
return foundUser; return foundUser;
} else { } else {
return when.reject(new errors.BadRequestError('User is already registered.')); return when.reject(new errors.BadRequestError('User is already registered.'));
@ -192,12 +192,21 @@ users = {
options: {} options: {}
}] }]
}; };
return mail.send(payload); return mail.send(payload).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 () { }).then(function () {
return when.resolve({users: [user]}); return when.resolve({users: [user]});
}).otherwise(function (error) { }).otherwise(function (error) {
if (error && error.type === 'EmailError') { if (error && error.type === 'EmailError') {
error.message = 'Error sending email: ' + error.message + ' Please check your email settings and resend the invitation.'; error.message = 'Error sending email: ' + error.message + ' Please check your email settings and resend the invitation.';
// If sending the invitation failed, set status to invited-pending
return dataProvider.User.edit({status: 'invited-pending'}, {id: user.id}).then(function () {
return when.reject(error);
});
} }
return when.reject(error); return when.reject(error);
}); });