diff --git a/dzen-assistant/admin/src/App.tsx b/dzen-assistant/admin/src/App.tsx index 8ec4da4..bfe4b65 100644 --- a/dzen-assistant/admin/src/App.tsx +++ b/dzen-assistant/admin/src/App.tsx @@ -17,7 +17,6 @@ import { ImagePlus, Link2, Loader2, - LogIn, Radio, RefreshCw, Save, @@ -375,6 +374,18 @@ function loadVkIdSdk() { }) } +function ToastNotice({ message, onClose }: { message: string; onClose?: () => void }) { + if (!message) return null + return ( +
+
+ {message} + {onClose ? : null} +
+
+ ) +} + function AuthScreen({ hasPasskeys, onAuthenticated }: { hasPasskeys: boolean; onAuthenticated: () => void }) { const [message, setMessage] = useState("") const [busy, setBusy] = useState(false) @@ -444,25 +455,6 @@ function AuthScreen({ hasPasskeys, onAuthenticated }: { hasPasskeys: boolean; on } } - async function registerPasskey() { - if (!vkAuthenticated) { - setMessage("Сначала войдите через VK ID.") - return - } - setBusy(true) - try { - const started = await api<{ challengeId: string; options: any }>("/api/auth/register/options", { method: "POST" }) - const credential = await navigator.credentials.create({ publicKey: registrationOptionsForBrowser(started.options) }) as PublicKeyCredential | null - if (!credential) throw new Error("Регистрация passkey отменена") - await api("/api/auth/register/verify", { method: "POST", body: JSON.stringify({ challengeId: started.challengeId, credential: serializePublicKeyCredential(credential) }) }) - onAuthenticated() - } catch (error) { - setMessage(error instanceof Error ? error.message : String(error)) - } finally { - setBusy(false) - } - } - return (
@@ -470,7 +462,7 @@ function AuthScreen({ hasPasskeys, onAuthenticated }: { hasPasskeys: boolean; on Логотип Дзен-ассистента

Дзен-ассистент

Вход в редакторскую панель

- {message ?
{message}
: null} + setMessage("")} />
{hasPasskeys ? ( - ) : null} - {!hasPasskeys ?

После входа через VK ID можно будет добавить Face ID, Touch ID или Windows Hello.

: null} - + {!hasPasskeys ?

После входа через VK ID добавьте биометрию в разделе «Настройки».

: null}
) @@ -676,6 +660,7 @@ function SettingsPanel({ onBack, onSaved }: { onBack: () => void; onSaved: (sett const [saving, setSaving] = useState(false) const [dirty, setDirty] = useState(false) const [message, setMessage] = useState("") + const [passkeyBusy, setPasskeyBusy] = useState(false) const signatureHolderRef = useRef(null) const signatureEditorRef = useRef(null) @@ -745,6 +730,21 @@ function SettingsPanel({ onBack, onSaved }: { onBack: () => void; onSaved: (sett } } + async function registerPasskey() { + setPasskeyBusy(true) + try { + const started = await api<{ challengeId: string; options: any }>("/api/auth/register/options", { method: "POST" }) + const credential = await navigator.credentials.create({ publicKey: registrationOptionsForBrowser(started.options) }) as PublicKeyCredential | null + if (!credential) throw new Error("Регистрация устройства отменена") + await api("/api/auth/register/verify", { method: "POST", body: JSON.stringify({ challengeId: started.challengeId, credential: serializePublicKeyCredential(credential) }) }) + setMessage("Устройство зарегистрировано для входа по биометрии") + } catch (error) { + setMessage(`Не удалось зарегистрировать устройство: ${error instanceof Error ? error.message : String(error)}`) + } finally { + setPasskeyBusy(false) + } + } + return (
@@ -757,7 +757,7 @@ function SettingsPanel({ onBack, onSaved }: { onBack: () => void; onSaved: (sett К роликам
- {message ?
{message}
: null} + setMessage("")} /> {loading ? ( Загрузка настроек... ) : ( @@ -791,6 +791,10 @@ function SettingsPanel({ onBack, onSaved }: { onBack: () => void; onSaved: (sett )}
+ - {statusMessage ?
{statusMessage}
: null}
) : null} @@ -2071,11 +2084,6 @@ export default function App() { ) : null} {selectedArticle ? (
- {copyToast ? ( -
- {copyToast} -
- ) : null}