How to handle restricted publish data for users?

Hi,
I am using alanning:roles to classify users. I have certain publications where only users with ‘admin’ roles have access to any data from publication.

If I early exit and return nothing, I get an exception about Error: Publish function can only return a Cursor or an array of Cursors

Any help will be much appreciated about how to early exit and handle the error display to the user??

You can use

if (!isAdmin){
  return this.ready();
} 

It basically just says “nothing to see here, move along”

Thanks @valentin, I will checkout the snippet.

Hey, this seems to work. Thanks heaps. Out of curiocity, would you be kind enough to shed some lights on the difference between returning empty array vs returning this.ready()