fix: 2 fixes

This commit is contained in:
Alexander Medvedev 2026-08-31 16:49:47 +02:00
parent db46670a99
commit 7ea58a985c
4 changed files with 23 additions and 7 deletions

View File

@ -132,7 +132,7 @@ export const SecuritySetupCards: React.FC<SecuritySetupCardsProps> = ({
setPasskeyError(null);
const startRes = await api.post('/user/passkey/register/start');
const options = startRes.data;
const options = startRes.data?.publicKey || startRes.data;
const credential = await startRegistration({ optionsJSON: options });

View File

@ -379,7 +379,8 @@ const ProfilePage = () => {
setPasskeyRegistering(true);
try {
const startRes = await api.post('/user/passkey/register/start');
const credential = await startRegistration({ optionsJSON: startRes.data });
const options = startRes.data?.publicKey || startRes.data;
const credential = await startRegistration({ optionsJSON: options });
const finishRes = await api.post('/user/passkey/register/finish', {
name: newPasskeyName.trim() || 'My Passkey',
credential,

View File

@ -137,8 +137,9 @@ const LoginPage = () => {
email: form.email.trim() || undefined,
});
const options = startRes.data?.options?.publicKey || startRes.data?.options || startRes.data?.publicKey || startRes.data;
const credential = await startAuthentication({
optionsJSON: startRes.data.options,
optionsJSON: options,
});
const finishRes = await api.post('/auth/passkey/login/finish', {

View File

@ -146,10 +146,24 @@ const StoreListing = ({ plugin, onSaved }: Props) => {
const [saveError, setSaveError] = useState<string | null>(null);
const [name, setName] = useState(plugin.name);
const [descriptions, setDescriptions] = useState<Record<string, string>>(() => {
const parsed = JSON.parse(plugin.translated_descriptions || '{}');
// Ensure default locale always exists
if (!parsed[DEFAULT_LOCALE]) parsed[DEFAULT_LOCALE] = parsed['en'] ?? '';
return parsed;
let parsed: Record<string, unknown> = {};
try { parsed = JSON.parse(plugin.translated_descriptions || '{}'); } catch { /* ignore */ }
// Normalize: if a value is a nested object (old format), extract its 'description' string.
const flat: Record<string, string> = {};
for (const [k, v] of Object.entries(parsed)) {
if (typeof v === 'string') {
flat[k] = v;
} else if (v && typeof v === 'object' && 'description' in v) {
flat[k] = String((v as Record<string, unknown>).description ?? '');
}
}
// Ensure the default locale always exists.
if (!flat[DEFAULT_LOCALE]) {
flat[DEFAULT_LOCALE] = flat['en-GB'] ?? flat['en'] ?? '';
}
return flat;
});
const [activeLocale, setActiveLocale] = useState(DEFAULT_LOCALE);
const [category, setCategory] = useState(plugin.category);