maeshinshin 1 год назад
Родитель
Сommit
b8bce7a063

+ 1 - 1
apps/app/src/server/models/user-group-relation.ts

@@ -128,7 +128,7 @@ schema.statics.findAllRelationForUserGroups = function(userGroups) {
  * @memberof UserGroupRelation
  */
 schema.statics.findAllGroupsForUser = async function(user): Promise<UserGroupDocument[]> {
-  const userGroupRelations = await this.find({ relatedUser: user.id }).populate('relatedGroup');
+  const userGroupRelations = await this.find({ relatedUser: user._id }).populate('relatedGroup');
   const userGroups = userGroupRelations.map((relation) => {
     return isPopulated(relation.relatedGroup) ? relation.relatedGroup as UserGroupDocument : null;
   });

+ 1 - 1
apps/app/src/server/service/page-grant.ts

@@ -276,7 +276,7 @@ class PageGrantService implements IPageGrantService {
     ).length === 0;
 
     if (!userBelongsToAllPreviousGrantedGroups) {
-      if (grant !== PageGrant.GRANT_USER_GROUP) {
+      if (Number(grant) !== PageGrant.GRANT_USER_GROUP) {
         return false;
       }
       const pageGrantIncludesUserRelatedGroup = hasIntersection(grantedGroups?.map(g => getIdForRef(g.item)) || [], userRelatedGroupIds);

+ 1 - 1
apps/app/src/server/util/compare-objectId.ts

@@ -1,6 +1,6 @@
 import mongoose from 'mongoose';
 
-import { ObjectIdLike } from '~/server/interfaces/mongoose-utils';
+import type { ObjectIdLike } from '~/server/interfaces/mongoose-utils';
 
 type IObjectId = mongoose.Types.ObjectId;
 const ObjectId = mongoose.Types.ObjectId;