Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ui error when no auth providers configured #1640

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to add a translation string and regenerate translations in case you're adding new text like that.

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
Loading