Skip to content

Commit 4e33784

Browse files
committed
fixup! fix(clerk-js): show error message when account is locked
1 parent 53fc56f commit 4e33784

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/clerk-js/src/ui/components/SignIn/SignInFactorOnePasswordCard.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export const SignInFactorOnePasswordCard = (props: SignInFactorOnePasswordProps)
8383
})
8484
.catch(err => {
8585
if (isUserLockedError(err)) {
86-
card.setError(err.errors[0]);
8786
// @ts-expect-error -- private method for the time being
8887
return clerk.__internal_navigateWithError('..', err.errors[0]);
8988
}

packages/clerk-js/src/ui/elements/contexts/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { FloatingTree, useFloatingParentNodeId } from '@floating-ui/react';
44
import React from 'react';
55

66
import { useLocalizations } from '../../customizables';
7-
import { useSafeState } from '../../hooks';
87

98
type Status = 'idle' | 'loading' | 'error';
109
type Metadata = string | undefined;
@@ -19,11 +18,17 @@ const [CardStateCtx, _useCardState] = createContextAndHook<CardStateCtxValue>('C
1918
export const CardStateProvider = (props: React.PropsWithChildren<any>) => {
2019
const { translateError } = useLocalizations();
2120

22-
const [state, setState] = useSafeState<State>({
21+
const [state, setState] = React.useState<State>(() => ({
2322
status: 'idle',
2423
metadata: undefined,
2524
error: translateError(window?.Clerk?.__internal_last_error || undefined),
26-
});
25+
}));
26+
27+
const lastError = window?.Clerk?.__internal_last_error;
28+
if (lastError) {
29+
console.log('CardStateProvider: setting error', lastError);
30+
setState(s => ({ ...s, error: translateError(lastError) }));
31+
}
2732

2833
const value = React.useMemo(() => ({ value: { state, setState } }), [state, setState]);
2934
return <CardStateCtx.Provider value={value}>{props.children}</CardStateCtx.Provider>;

0 commit comments

Comments
 (0)