Skip to content

Commit ee2c352

Browse files
Jaskonumputun
authored andcommitted
fix: ui error when no auth providers configured
1 parent 9c718cb commit ee2c352

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

frontend/apps/remark42/app/components/auth/auth.messsages.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,8 @@ export const messages = defineMessages<string>({
9393
id: 'auth.signout',
9494
defaultMessage: 'Sign Out',
9595
},
96+
noProviders: {
97+
id: 'auth.no-providers',
98+
defaultMessage: 'No providers available. May be you forgot to enable them?',
99+
},
96100
});

frontend/apps/remark42/app/components/auth/auth.spec.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,15 @@ describe('<Auth/>', () => {
253253
expect(input).toHaveValue(expected);
254254
});
255255

256+
it('should show error when no auth providers are configured', () => {
257+
StaticStore.config.auth_providers = [];
258+
259+
const { container } = render(<Auth />);
260+
261+
fireEvent.click(screen.getByText('Sign In'));
262+
expect(container.querySelector('.auth-error')).toBeInTheDocument();
263+
});
264+
256265
describe('OAuth providers', () => {
257266
it('should not set user if unauthorized', async () => {
258267
StaticStore.config.auth_providers = ['google'];

frontend/apps/remark42/app/components/auth/auth.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ export function Auth() {
201201
</Button>
202202
{isDropdownShown && (
203203
<div className={clsx('auth-dropdown', styles.dropdown)} ref={ref}>
204+
{!hasOAuthProviders && !hasFormProviders && (
205+
<div className={clsx('auth-error', styles.error)}>{intl.formatMessage(messages.noProviders)}</div>
206+
)}
204207
<form className={clsx('auth-form', styles.form)} onSubmit={handleSubmit}>
205208
{view === 'telegram' && telegramParamsRef.current !== null ? (
206209
<>

0 commit comments

Comments
 (0)