fix(i18n): preserve public auth commands and feedback across language changes
This commit is contained in:
@@ -20,7 +20,7 @@ export default function TwoFactorChallenge({
|
||||
const [code, setCode] = useState("");
|
||||
const [trustDevice, setTrustDevice] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [error, setError] = useState<{ cause: unknown; rateLimited: boolean } | null>(null);
|
||||
|
||||
async function submit() {
|
||||
setLoading(true);
|
||||
@@ -29,11 +29,7 @@ export default function TwoFactorChallenge({
|
||||
const res = await api.post<ChallengeResponse>("/auth/2fa/challenge", { pendingToken, code, trustDevice });
|
||||
onSuccess(res.data);
|
||||
} catch (e: any) {
|
||||
if (e?.response?.status === 429) {
|
||||
setError(t("twoFactorRateLimited"));
|
||||
} else {
|
||||
setError(getApiErrorMessage(e, t("twoFactorInvalidCode")));
|
||||
}
|
||||
setError({ cause: e, rateLimited: e?.response?.status === 429 });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -54,7 +50,7 @@ export default function TwoFactorChallenge({
|
||||
{t("twoFactorHint")}
|
||||
</Typography>
|
||||
|
||||
{error ? <Alert severity="error" role="alert">{error}</Alert> : null}
|
||||
{error ? <Alert severity="error" role="alert">{error.rateLimited ? t("twoFactorRateLimited") : getApiErrorMessage(error.cause, t("twoFactorInvalidCode"))}</Alert> : null}
|
||||
|
||||
<TextField
|
||||
label={t("twoFactorCodeLabel")}
|
||||
|
||||
Reference in New Issue
Block a user