Skip to content

Commit

Permalink
fix(api-admin-users-cognito): catch and ignore errors during migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Nov 3, 2021
1 parent d4c13fe commit 112830f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/api-admin-users-cognito/src/migration/index.ts
Expand Up @@ -187,6 +187,16 @@ export const migration = (context: Context) => {
};
});

// Cognito users already exist, and we should not abort user creation when Cognito throws an error.
const originalPublish = adminUsers.onUserBeforeCreate.publish;
adminUsers.onUserBeforeCreate.publish = async event => {
try {
await originalPublish(event);
} catch (err) {
// Ignore error
}
};

for (const user of newUsers) {
await adminUsers.createUser(user);
}
Expand Down

0 comments on commit 112830f

Please sign in to comment.