I want to use both userPool and identityPool auth modes in my Amplify Gen 2 app. I need unauthenticated users to have read-only access, and authenticated users to have full access. But currently, I can only use one auth mode. How can I enable both?
import { type ClientSchema, a, defineData } from '@aws-amplify/backend';
const schema = a.schema({
Listing: a.model({
title: a.string(),
description: a.string(),
imageUrl: a.string(),
price: a.float(),
sellerId: a.string(),
category: a.string(),
location: a.string(),
createdAt: a.datetime(),
}).authorization((allow) => [
allow.authenticated(),
allow.guest().to(['read']),
]),
RentOrder: a.model({
advId: a.string(),
borrowerUserId: a.string(),
lenderUserID: a.string(),
borrowerEmailID: a.string(),
lenderEmailID: a.string(),
rentValue: a.string(),
commonID: a.string(),
}).authorization((allow) => [allow.authenticated()])
});
export type Schema = ClientSchema<typeof schema>;
export const data = defineData({
schema,
authorizationModes: {
defaultAuthorizationMode: 'userPool'
},
});