238632402c
refs https://github.com/TryGhost/Team/issues/587 refse30b9735fa
- It was not possible to invite a new Contributor to a site that has reached its limit - This fix divides the resend invite action into two separate steps: 1. Deleting existing invite 2. Creating a new one for the same data - It was hitting the limit because the permissions were correctly checking for "add" action being executed when the limit of invites/staff users was already used up. By removing existing invite we mimic the behavior the server would do for us anyway (2111992dd4/core/server/services/invites/invites.js (L18-L22)
) Co-authored-by: Rish <zrishabhgarg@gmail.com>
36 lines
975 B
JavaScript
36 lines
975 B
JavaScript
import Model, {attr, belongsTo} from '@ember-data/model';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default Model.extend({
|
|
token: attr('string'),
|
|
email: attr('string'),
|
|
expires: attr('number'),
|
|
createdAtUTC: attr('moment-utc'),
|
|
createdBy: attr('number'),
|
|
updatedAtUTC: attr('moment-utc'),
|
|
updatedBy: attr('number'),
|
|
status: attr('string'),
|
|
|
|
role: belongsTo('role', {async: false}),
|
|
|
|
ajax: service(),
|
|
ghostPaths: service(),
|
|
|
|
resend() {
|
|
let inviteData = {
|
|
email: this.email,
|
|
role_id: this.role.id
|
|
};
|
|
|
|
let inviteUrl = this.get('ghostPaths.url').api('invites');
|
|
|
|
return this.ajax.del(`${inviteUrl}${this.get('id')}`)
|
|
.then(() => {
|
|
return this.ajax.post(inviteUrl, {
|
|
data: JSON.stringify({invites: [inviteData]}),
|
|
contentType: 'application/json'
|
|
});
|
|
});
|
|
}
|
|
});
|