Skip to content

Commit

Permalink
fix(auth): Unauthenticated identity throws AuthError without user … (#…
Browse files Browse the repository at this point in the history
…10090)

Co-authored-by: Aaron S <94858815+stocaaro@users.noreply.github.com>
  • Loading branch information
khatruong2009 and stocaaro authored Jul 29, 2022
1 parent e197950 commit 2ac9035
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions packages/auth/__tests__/auth-unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1736,13 +1736,12 @@ describe('auth unit test', () => {
identityPoolId: 'awsCognitoIdentityPoolId',
mandatorySignIn: false,
});
const errorMessage = new NoUserPoolError(
AuthErrorTypes.MissingAuthConfig
);

const noUserPoolError = Error('No User Pool in the configuration.');

expect.assertions(2);
expect(auth.currentSession().then()).rejects.toThrow(NoUserPoolError);
expect(auth.currentSession().then()).rejects.toEqual(errorMessage);
expect(auth.currentSession().then()).rejects.toThrow(Error);
expect(auth.currentSession().then()).rejects.toEqual(noUserPoolError);
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@ export class AuthClass {
logger.debug('Getting current session');
// Purposely not calling the reject method here because we don't need a console error
if (!this.userPool) {
return this.rejectNoUserPool();
return Promise.reject(new Error('No User Pool in the configuration.'));
}

return new Promise((res, rej) => {
Expand Down

0 comments on commit 2ac9035

Please sign in to comment.