Apostrophe CMS Main Site Forum Home

Using apostrophe-headless, can I filter model properties for non-logged-in users?


#1

I have an apostrophe-headless and a custom module served through it:

module.exports = {
  extend: 'apostrophe-pieces',
  name: 'book',
  label: 'Book',
  pluralLabel: 'Books',
  restApi: true,
  addFields: [
    {
      name: 'name',
      label: 'Name',
      type: 'string'
    },
    {
      name: 'description',
      label: 'Description',
      type: 'string',
      textarea: true
    },
    {
      name: 'author',
      label: 'Author',
      type: 'string'
    },
    {
      name: 'author_email',
      label: 'Author Email',
      type: 'string'
    }
  }
  ...
}

Is there a way to not return the author_email property if the user fetching it is not logged in?