mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-19 05:55:34 +09:00
fix(auth): require a hashed poll secret for desktop handoff (#2357)
This commit is contained in:
1 parent
b82681b77a
commit
f703969e80
45 files changed
+382
-188
No files matched your search
@@ -38,6 +38,7 @@ const BrowserLoginHandoffModal = observer(({onSuccess, prefillEmail}: BrowserLog
|
||||
const [isGenerating, setIsGenerating] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const pollingRef = useRef(false);
|
||||
const handoffPollSecretRef = useRef<string | null>(null);
|
||||
const completedRef = useRef(false);
|
||||
const generateCode = useCallback(async () => {
|
||||
setIsGenerating(true);
|
||||
@@ -46,6 +47,7 @@ const BrowserLoginHandoffModal = observer(({onSuccess, prefillEmail}: BrowserLog
|
||||
setHandoffExpiresAt(null);
|
||||
try {
|
||||
const result = await AuthenticationCommands.initiateDesktopHandoff();
|
||||
handoffPollSecretRef.current = result.poll_secret ?? null;
|
||||
setHandoffCode(result.code);
|
||||
setHandoffExpiresAt(result.expires_at);
|
||||
} catch (e) {
|
||||
@@ -63,7 +65,7 @@ const BrowserLoginHandoffModal = observer(({onSuccess, prefillEmail}: BrowserLog
|
||||
const timer = setInterval(async () => {
|
||||
if (!pollingRef.current) return;
|
||||
try {
|
||||
const result = await AuthenticationCommands.pollDesktopHandoffStatus(handoffCode);
|
||||
const result = await AuthenticationCommands.pollDesktopHandoffStatus(handoffCode, handoffPollSecretRef.current);
|
||||
if (result.status === 'completed' && result.token && result.user_id) {
|
||||
pollingRef.current = false;
|
||||
completedRef.current = true;
|
||||
|
||||
Reference in new issue
Block a user