this.unblock();
I think it is no longer required in V3 since it is a Fiber thing (meteor/packages/ddp-server/livedata_server.js at 618e5a24baf8948323414b44ab5e686311055c04 · meteor/meteor · GitHub).
Ok, Security.hasRole is an async function inside and async function. In order to reach to the final return of getAnnouncement you need the resolutions of the async functions Security.xxxxx.
I think you need to await the Security function. What happens there is that you throw an error into a function and the resolution of that function is not “bubbling up” to the method level because you don’t await for a return or an error.
Can you try 2 things and let’s see if anything changes:
const auth = await Security.hasRole(....)
console.log(auth)
and
final return of your method, will return the return in 'then'
return await Security.hasRole(this.userId, ["supplier_community_read"])
.then(auth => {
if (auth) {
return await AnnouncementService.getAnnouncement(
announcementID,
this.userId
)
}
})
.catch(err => console.log(err)) // you are catching at the method level the error thrown in a function in the depth of your function.