mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 12:01:13 +00:00
fix: harden app lock system unlock flow
This commit is contained in:
1 parent
f6a49dbf0a
commit
0ea707f70f
14 files changed
+114
-26
No files matched your search
@@ -196,11 +196,14 @@ export function useAppLockState(settings: AppLockSettings) {
|
||||
return result;
|
||||
}, [bridge, refreshRuntimeState, refreshSystemUnlockStatus, setRuntimeState]);
|
||||
|
||||
const reset = useCallback(async () => {
|
||||
const reset = useCallback(async (currentPassword: string) => {
|
||||
if (typeof bridge?.requestAppLockReset !== 'function') {
|
||||
throw new Error('App Lock reset bridge is unavailable');
|
||||
}
|
||||
await bridge.requestAppLockReset();
|
||||
const result = await bridge.requestAppLockReset(currentPassword);
|
||||
if (result && typeof result === 'object' && 'ok' in result && result.ok === false) {
|
||||
throw new Error(result.error);
|
||||
}
|
||||
const unlockedAt = Date.now();
|
||||
setRuntimeState((current) => createOptimisticUnlockedRuntimeState(current, unlockedAt));
|
||||
await refreshRuntimeState().catch(() => {});
|
||||
|
||||
Reference in new issue
Block a user