Skip to content

Commit 322f3e5

Browse files
authored
Merge pull request #4127 from ProjectMirador/auth-regression
Fix auth regression from #4072
2 parents ab5d316 + 6cacd48 commit 322f3e5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

__tests__/src/components/IIIFAuthentication.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ describe('IIIFAuthentication', () => {
6161
expect(handleAuthInteraction).toHaveBeenCalledWith('w', 'http://example.com/auth');
6262
});
6363
});
64+
describe('with a failed external authentication', () => {
65+
it('renders with an error message', async () => {
66+
const handleAuthInteraction = vi.fn();
67+
createWrapper({
68+
accessTokenServiceId: null, handleAuthInteraction, isInteractive: false, status: 'failed',
69+
});
70+
expect(screen.getByText('Login failed')).toBeInTheDocument();
71+
expect(screen.getByText('... and this is why.')).toBeInTheDocument();
72+
});
73+
});
6474
describe('in the middle of authenticating', () => {
6575
it('does the IIIF access cookie behavior', async () => {
6676
const mockWindow = { close: vi.fn(), closed: false };

src/components/IIIFAuthentication.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export function IIIFAuthentication({
1717
}) {
1818
const { t } = useTranslation();
1919

20-
if (!accessTokenServiceId || !authServiceId) return null;
21-
2220
/** */
2321
const onReceiveAccessTokenMessage = (payload) => {
2422
resolveAccessTokenRequest(authServiceId, accessTokenServiceId, payload);
@@ -98,6 +96,7 @@ export function IIIFAuthentication({
9896
);
9997
};
10098

99+
if (!authServiceId) return null;
101100
if (status === null) return renderLogin();
102101
if (status === 'cookie') return renderLoggingInCookie();
103102
if (status === 'token') return renderLoggingInToken();

0 commit comments

Comments
 (0)