4
유성에 대해 yogiben:admin 패키지를 사용하고 있으며 현재 로그인 한 사용자가 각 컬렉션에서 자신의 개체 만 볼 수 있기를 바랍니다.Meteor Yogiben : 로그인 사용자 필터링
구독을 관리자에게 어떻게 통합합니까? 자동 서식의 일부입니까?
유성에 대해 yogiben:admin 패키지를 사용하고 있으며 현재 로그인 한 사용자가 각 컬렉션에서 자신의 개체 만 볼 수 있기를 바랍니다.Meteor Yogiben : 로그인 사용자 필터링
구독을 관리자에게 어떻게 통합합니까? 자동 서식의 일부입니까?
그래서 알아 내기 시작했습니다.
https://stackoverflow.com/a/30864393/55124가 지금은 게시를 편집 할 lib 디렉토리/서버/publish.coffee 파일로 찾고 있어요 :
나는 여기에 설명 된 기술을 사용하여 패키지를 복제.Meteor.publishComposite 'adminCollectionDoc', (collection, id) ->
check collection, String
check id, Match.OneOf(String, Mongo.ObjectID)
if Roles.userIsInRole this.userId, ['admin']
find: ->
adminCollectionObject(collection).find(id)
children: AdminConfig?.collections?[collection]?.children or []
else
@ready()
Meteor.publish 'adminUsers', ->
if Roles.userIsInRole @userId, ['admin']
Meteor.users.find()
else
@ready()
Meteor.publish 'adminUser', ->
Meteor.users.find @userId
Meteor.publish 'adminCollectionsCount', ->
handles = []
self = @
_.each AdminTables, (table, name) ->
id = new Mongo.ObjectID
count = 0
table = AdminTables[name]
ready = false
selector = if table.selector then table.selector(self.userId) else {}
handles.push table.collection.find().observeChanges
added: ->
count += 1
ready and self.changed 'adminCollectionsCount', id, {count: count}
removed: ->
count -= 1
ready and self.changed 'adminCollectionsCount', id, {count: count}
ready = true
self.added 'adminCollectionsCount', id, {collection: name, count: count}
self.onStop ->
_.each handles, (handle) -> handle.stop()
self.ready()
Meteor.publish null, ->
Meteor.roles.find({})
그러나 둘 다 /가
return AdminTables[name] = new Tabular.Table({
name: name,
collection: adminCollectionObject(name),
pub: collection.children && adminTablePubName(name),
sub: collection.sub,
columns: columns,
extraFields: collection.extraFields,
dom: adminTablesDom,
selector: collection.selector || function(userId) {
return { owner: userId };
}
빈 선택기 함수가 있었고, 난이 반환 소유자를 추가 한 startup.js /는 LIB의 라인을 변경하는 것만 큼 간단 밝혀 : userId.