Skip to content

Commit

Permalink
fix: handle error when no aws secrets provided
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozwiaczek committed Dec 10, 2020
1 parent 7a93c40 commit 62a5517
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IntentbaseProvider } from '../src/providers/IntentbaseProvider';
export const decorators = [
(Story) => (
<IntentbaseProvider
environment={process.env.AWS_COGNITO_REGION || 'development'}
environment={process.env.AWS_COGNITO_REGION}
awsCognitoRegion={process.env.AWS_COGNITO_REGION}
awsCognitoUserPoolId={process.env.AWS_COGNITO_USER_POOL_ID}
awsCognitoUserPoolWebClientId={process.env.AWS_COGNITO_USER_POOL_CLIENT_ID}
Expand Down
11 changes: 2 additions & 9 deletions src/providers/IntentbaseProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type Environment = 'production' | 'development' | 'test';
interface IntentbaseProps {
theme?: Partial<Theme> | ((outerTheme: Theme) => Theme);
awsCognitoRegion?: string;
awsCognitoUserPoolId?: string;
awsCognitoUserPoolWebClientId?: string;
awsCognitoUserPoolId: string;
awsCognitoUserPoolWebClientId: string;
environment?: Environment;
getApiUser?: (cognitoUser?: CognitoUser) => Promise<any>;
}
Expand All @@ -29,13 +29,6 @@ export const IntentbaseProvider: FC<IntentbaseProps> = ({
environment = 'production',
getApiUser,
}) => {
if (!awsCognitoUserPoolId || !awsCognitoUserPoolWebClientId) {
if (environment !== 'production') {
return <h1>AWS Secrets required</h1>;
}
return null;
}

try {
configureAmplify(awsCognitoRegion, awsCognitoUserPoolId, awsCognitoUserPoolWebClientId);
} catch (error) {
Expand Down

0 comments on commit 62a5517

Please sign in to comment.