Skip to content

Commit

Permalink
fix: ui error when no auth providers configured
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaskon authored and paskal committed Sep 16, 2023
1 parent 40a0d7c commit 74fd5a8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions frontend/apps/remark42/app/components/auth/auth.messsages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ export const messages = defineMessages<string>({
id: 'auth.signout',
defaultMessage: 'Sign Out',
},
noProviders: {
id: 'auth.no-providers',
defaultMessage: 'No providers available. May be you forgot to enable them?',
},
});
9 changes: 9 additions & 0 deletions frontend/apps/remark42/app/components/auth/auth.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,15 @@ describe('<Auth/>', () => {
expect(input).toHaveValue(expected);
});

it('should show error when no auth providers are configured', () => {
StaticStore.config.auth_providers = [];

const { container } = render(<Auth />);

fireEvent.click(screen.getByText('Sign In'));
expect(container.querySelector('.auth-error')).toBeInTheDocument();
});

describe('OAuth providers', () => {
it('should not set user if unauthorized', async () => {
StaticStore.config.auth_providers = ['google'];
Expand Down
3 changes: 3 additions & 0 deletions frontend/apps/remark42/app/components/auth/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ export function Auth() {
</Button>
{isDropdownShown && (
<div className={clsx('auth-dropdown', styles.dropdown)} ref={ref}>
{!hasOAuthProviders && !hasFormProviders && (
<div className={clsx('auth-error', styles.error)}>{intl.formatMessage(messages.noProviders)}</div>
)}
<form className={clsx('auth-form', styles.form)} onSubmit={handleSubmit}>
{view === 'telegram' && telegramParamsRef.current !== null ? (
<>
Expand Down

0 comments on commit 74fd5a8

Please sign in to comment.