diff --git a/server/core/auth.js b/server/core/auth.js index 81263fe7..ff5ca2ba 100644 --- a/server/core/auth.js +++ b/server/core/auth.js @@ -30,7 +30,7 @@ module.exports = { passport.deserializeUser(async (id, done) => { try { - const user = await WIKI.models.users.query().findById(id).modifyEager('groups', builder => { + const user = await WIKI.models.users.query().findById(id).withGraphFetched('groups').modifyGraph('groups', builder => { builder.select('groups.id', 'permissions') }) if (user) { diff --git a/server/models/pageHistory.js b/server/models/pageHistory.js index 145e9eeb..63e5f8fb 100644 --- a/server/models/pageHistory.js +++ b/server/models/pageHistory.js @@ -116,7 +116,7 @@ module.exports = class PageHistory extends Model { authorName: 'author.name' } ]) - .joinRelation('author') + .joinRelated('author') .where({ 'pageHistory.pageId': pageId }) @@ -138,7 +138,7 @@ module.exports = class PageHistory extends Model { authorName: 'author.name' } ]) - .joinRelation('author') + .joinRelated('author') .where({ 'pageHistory.pageId': pageId }) diff --git a/server/models/pages.js b/server/models/pages.js index 29a63e00..a6dc7c19 100644 --- a/server/models/pages.js +++ b/server/models/pages.js @@ -702,8 +702,8 @@ module.exports = class Page extends Model { creatorEmail: 'creator.email' } ]) - .joinRelation('author') - .joinRelation('creator') + .joinRelated('author') + .joinRelated('creator') .eagerAlgorithm(Model.JoinEagerAlgorithm) .eager('tags(selectTags)', { selectTags: builder => { diff --git a/server/models/users.js b/server/models/users.js index 4f123cbf..67f82bc4 100644 --- a/server/models/users.js +++ b/server/models/users.js @@ -331,7 +331,7 @@ module.exports = class User extends Model { static async refreshToken(user) { if (_.isSafeInteger(user)) { - user = await WIKI.models.users.query().findById(user).eager('groups').modifyEager('groups', builder => { + user = await WIKI.models.users.query().findById(user).withGraphFetched('groups').modifyGraph('groups', builder => { builder.select('groups.id', 'permissions') }) if (!user) { @@ -339,7 +339,7 @@ module.exports = class User extends Model { throw new WIKI.Error.AuthGenericError() } } else if (_.isNil(user.groups)) { - await user.$relatedQuery('groups').select('groups.id', 'permissions') + user.groups = await user.$relatedQuery('groups').select('groups.id', 'permissions') } return {