Skip to content

Commit

Permalink
Fix auth regression from #4072
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Mar 4, 2025
1 parent 5b8f60b commit 495b40f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 8 additions & 0 deletions __tests__/src/components/IIIFAuthentication.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ describe('IIIFAuthentication', () => {
expect(handleAuthInteraction).toHaveBeenCalledWith('w', 'http://example.com/auth');
});
});
describe('with a failed external authentication', () => {
it('renders with an error message', async () => {
const handleAuthInteraction = vi.fn();
createWrapper({ handleAuthInteraction, accessTokenServiceId: null, isInteractive: false, status: 'failed' });

Check failure on line 67 in __tests__/src/components/IIIFAuthentication.test.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected a line break before this closing brace

Check failure on line 67 in __tests__/src/components/IIIFAuthentication.test.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected object keys to be in insensitive ascending order. 'accessTokenServiceId' should be before 'handleAuthInteraction'

Check failure on line 67 in __tests__/src/components/IIIFAuthentication.test.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected a line break after this opening brace

Check failure on line 67 in __tests__/src/components/IIIFAuthentication.test.js

View workflow job for this annotation

GitHub Actions / build (22.x)

Expected a line break before this closing brace

Check failure on line 67 in __tests__/src/components/IIIFAuthentication.test.js

View workflow job for this annotation

GitHub Actions / build (22.x)

Expected object keys to be in insensitive ascending order. 'accessTokenServiceId' should be before 'handleAuthInteraction'

Check failure on line 67 in __tests__/src/components/IIIFAuthentication.test.js

View workflow job for this annotation

GitHub Actions / build (22.x)

Expected a line break after this opening brace

Check failure on line 67 in __tests__/src/components/IIIFAuthentication.test.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected a line break before this closing brace

Check failure on line 67 in __tests__/src/components/IIIFAuthentication.test.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected object keys to be in insensitive ascending order. 'accessTokenServiceId' should be before 'handleAuthInteraction'

Check failure on line 67 in __tests__/src/components/IIIFAuthentication.test.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected a line break after this opening brace
expect(screen.getByText('Login failed')).toBeInTheDocument();
expect(screen.getByText('... and this is why.')).toBeInTheDocument();
});
});
describe('in the middle of authenticating', () => {
it('does the IIIF access cookie behavior', async () => {
const mockWindow = { close: vi.fn(), closed: false };
Expand Down
3 changes: 1 addition & 2 deletions src/components/IIIFAuthentication.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export function IIIFAuthentication({
}) {
const { t } = useTranslation();

if (!accessTokenServiceId || !authServiceId) return null;

/** */
const onReceiveAccessTokenMessage = (payload) => {
resolveAccessTokenRequest(authServiceId, accessTokenServiceId, payload);
Expand Down Expand Up @@ -98,6 +96,7 @@ export function IIIFAuthentication({
);
};

if (!authServiceId) return null;
if (status === null) return renderLogin();
if (status === 'cookie') return renderLoggingInCookie();
if (status === 'token') return renderLoggingInToken();
Expand Down

0 comments on commit 495b40f

Please sign in to comment.