Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions src/tools/auth0/handlers/userAttributeProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,27 @@ export default class UserAttributeProfilesHandler extends DefaultAPIHandler {
async getType() {
if (this.existing) return this.existing;

this.existing = await paginate<UserAttributeProfile>(this.client.userAttributeProfiles.getAll, {
checkpoint: true,
include_totals: true,
is_global: false,
take: 10,
});
try {
this.existing = await paginate<UserAttributeProfile>(this.client.userAttributeProfiles.getAll, {
checkpoint: true,
include_totals: true,
is_global: false,
take: 10,
});

return this.existing;
return this.existing;
} catch (err) {
if (err.statusCode === 404 || err.statusCode === 501) {
return null;
}
if (err.statusCode === 403) {
log.debug(
'User Attribute Profile with Self-Service SSO is not enabled for this tenant. Please verify `scope` or contact Auth0 support to enable this feature.'
);
return null;
}
throw err;
}
}

@order('50')
Expand Down
13 changes: 13 additions & 0 deletions test/tools/auth0/handlers/userAttributeProfiles.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,18 @@ describe('#userAttributeProfiles handler', () => {

await stageFn.apply(handler, [{ userAttributeProfiles: [] }]);
});

it('should handle 403 error when not enabled on tenant', async () => {
const auth0 = {
userAttributeProfiles: {
getAll: () => Promise.reject(Object.assign(new Error('Forbidden'), { statusCode: 403 })),
},
};

const handler = new userAttributeProfiles.default({ client: pageClient(auth0), config });

const data = await handler.getType();
expect(data).to.equal(null);
});
});
});