mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Replaced Promise.join() with .all() in user model (#14972)
refs: https://github.com/TryGhost/Ghost/issues/14882 - Usage of bluebird is deprecated in favour of using native promises
This commit is contained in:
parent
57a786c63c
commit
d9f0db6a22
2 changed files with 14 additions and 7 deletions
|
@ -1005,10 +1005,10 @@ User = ghostBookshelf.Model.extend({
|
|||
let ownerRole;
|
||||
let contextUser;
|
||||
|
||||
return Promise.join(
|
||||
return Promise.all([
|
||||
ghostBookshelf.model('Role').findOne({name: 'Owner'}),
|
||||
User.findOne({id: options.context.user}, {withRelated: ['roles']})
|
||||
)
|
||||
])
|
||||
.then((results) => {
|
||||
ownerRole = results[0];
|
||||
contextUser = results[1];
|
||||
|
@ -1021,8 +1021,10 @@ User = ghostBookshelf.Model.extend({
|
|||
}));
|
||||
}
|
||||
|
||||
return Promise.join(ghostBookshelf.model('Role').findOne({name: 'Administrator'}),
|
||||
User.findOne({id: object.id}, {withRelated: ['roles']}));
|
||||
return Promise.all([
|
||||
ghostBookshelf.model('Role').findOne({name: 'Administrator'}),
|
||||
User.findOne({id: object.id}, {withRelated: ['roles']})
|
||||
]);
|
||||
})
|
||||
.then((results) => {
|
||||
const adminRole = results[0];
|
||||
|
@ -1049,9 +1051,11 @@ User = ghostBookshelf.Model.extend({
|
|||
}
|
||||
|
||||
// convert owner to admin
|
||||
return Promise.join(contextUser.roles().updatePivot({role_id: adminRole.id}),
|
||||
return Promise.all([
|
||||
contextUser.roles().updatePivot({role_id: adminRole.id}),
|
||||
user.roles().updatePivot({role_id: ownerRole.id}),
|
||||
user.id);
|
||||
user.id
|
||||
]);
|
||||
})
|
||||
.then((results) => {
|
||||
return Users.forge()
|
||||
|
|
|
@ -212,7 +212,10 @@ describe('User Model', function run() {
|
|||
|
||||
it('can findOne by role name', function () {
|
||||
return testUtils.fixtures.createExtraUsers().then(function () {
|
||||
return Promise.join(UserModel.findOne({role: 'Owner'}), UserModel.findOne({role: 'Editor'}));
|
||||
return Promise.all([
|
||||
UserModel.findOne({role: 'Owner'}),
|
||||
UserModel.findOne({role: 'Editor'})
|
||||
]);
|
||||
}).then(function (results) {
|
||||
let owner = results[0];
|
||||
let editor = results[1];
|
||||
|
|
Loading…
Add table
Reference in a new issue