mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
🐛 fix guard for inviting owner in setup/three (#786)
refs https://github.com/TryGhost/Ghost/issues/8692 - fixes the guard on setup/three against inviting the owner user set up on setup/two (we were sending invites for every e-mail in the list rather than only valid e-mails) - adds a check to see if we get any invalid errors from the server and will show those separately to the `x emails failed to send` alert
This commit is contained in:
parent
7e595d4be7
commit
a99ecf4818
1 changed files with 8 additions and 3 deletions
|
@ -7,6 +7,7 @@ import injectService from 'ember-service/inject';
|
|||
import run from 'ember-runloop';
|
||||
import {A as emberA} from 'ember-array/utils';
|
||||
import {htmlSafe} from 'ember-string';
|
||||
import {isInvalidError} from 'ember-ajax/errors';
|
||||
import {task, timeout} from 'ember-concurrency';
|
||||
|
||||
const {Errors} = DS;
|
||||
|
@ -143,7 +144,7 @@ export default Controller.extend({
|
|||
},
|
||||
|
||||
invite: task(function* () {
|
||||
let users = this.get('usersArray');
|
||||
let users = this.get('validUsersArray');
|
||||
|
||||
if (this.validate() && users.length > 0) {
|
||||
this._hasTransitioned = false;
|
||||
|
@ -173,7 +174,7 @@ export default Controller.extend({
|
|||
}).drop(),
|
||||
|
||||
_saveInvites(authorRole) {
|
||||
let users = this.get('usersArray');
|
||||
let users = this.get('validUsersArray');
|
||||
|
||||
return RSVP.Promise.all(
|
||||
users.map((user) => {
|
||||
|
@ -187,8 +188,9 @@ export default Controller.extend({
|
|||
email: user,
|
||||
success: invite.get('status') === 'sent'
|
||||
};
|
||||
}).catch(() => {
|
||||
}).catch((error) => {
|
||||
return {
|
||||
error,
|
||||
email: user,
|
||||
success: false
|
||||
};
|
||||
|
@ -206,6 +208,9 @@ export default Controller.extend({
|
|||
invites.forEach((invite) => {
|
||||
if (invite.success) {
|
||||
successCount++;
|
||||
} else if (isInvalidError(invite.error)) {
|
||||
message = `${invite.email} was invalid: ${invite.error.errors[0].message}`;
|
||||
notifications.showAlert(message, {type: 'error', delayed: true, key: `signup.send-invitations.${invite.email}`});
|
||||
} else {
|
||||
erroredEmails.push(invite.email);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue