fix: 2 fixes
This commit is contained in:
parent
db46670a99
commit
7ea58a985c
@ -132,7 +132,7 @@ export const SecuritySetupCards: React.FC<SecuritySetupCardsProps> = ({
|
|||||||
setPasskeyError(null);
|
setPasskeyError(null);
|
||||||
|
|
||||||
const startRes = await api.post('/user/passkey/register/start');
|
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 });
|
const credential = await startRegistration({ optionsJSON: options });
|
||||||
|
|
||||||
|
|||||||
@ -379,7 +379,8 @@ const ProfilePage = () => {
|
|||||||
setPasskeyRegistering(true);
|
setPasskeyRegistering(true);
|
||||||
try {
|
try {
|
||||||
const startRes = await api.post('/user/passkey/register/start');
|
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', {
|
const finishRes = await api.post('/user/passkey/register/finish', {
|
||||||
name: newPasskeyName.trim() || 'My Passkey',
|
name: newPasskeyName.trim() || 'My Passkey',
|
||||||
credential,
|
credential,
|
||||||
|
|||||||
@ -137,8 +137,9 @@ const LoginPage = () => {
|
|||||||
email: form.email.trim() || undefined,
|
email: form.email.trim() || undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const options = startRes.data?.options?.publicKey || startRes.data?.options || startRes.data?.publicKey || startRes.data;
|
||||||
const credential = await startAuthentication({
|
const credential = await startAuthentication({
|
||||||
optionsJSON: startRes.data.options,
|
optionsJSON: options,
|
||||||
});
|
});
|
||||||
|
|
||||||
const finishRes = await api.post('/auth/passkey/login/finish', {
|
const finishRes = await api.post('/auth/passkey/login/finish', {
|
||||||
|
|||||||
@ -146,10 +146,24 @@ const StoreListing = ({ plugin, onSaved }: Props) => {
|
|||||||
const [saveError, setSaveError] = useState<string | null>(null);
|
const [saveError, setSaveError] = useState<string | null>(null);
|
||||||
const [name, setName] = useState(plugin.name);
|
const [name, setName] = useState(plugin.name);
|
||||||
const [descriptions, setDescriptions] = useState<Record<string, string>>(() => {
|
const [descriptions, setDescriptions] = useState<Record<string, string>>(() => {
|
||||||
const parsed = JSON.parse(plugin.translated_descriptions || '{}');
|
let parsed: Record<string, unknown> = {};
|
||||||
// Ensure default locale always exists
|
try { parsed = JSON.parse(plugin.translated_descriptions || '{}'); } catch { /* ignore */ }
|
||||||
if (!parsed[DEFAULT_LOCALE]) parsed[DEFAULT_LOCALE] = parsed['en'] ?? '';
|
|
||||||
return parsed;
|
// 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 [activeLocale, setActiveLocale] = useState(DEFAULT_LOCALE);
|
||||||
const [category, setCategory] = useState(plugin.category);
|
const [category, setCategory] = useState(plugin.category);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user