MCPcopy
hub / github.com/dataelement/Clawith / poll

Function poll

frontend/src/pages/SSOEntry.tsx:72–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70 let timer: number | undefined;
71
72 const poll = async () => {
73 if (cancelled) return;
74 try {
75 setPolling(true);
76 const res = await fetchJson<any>(`/sso/session/${sid}/status`);
77 if (res?.access_token && res?.user) {
78 setAuth(res.user, res.access_token);
79 if (res.user && !res.user.tenant_id) {
80 navigate('/setup-company');
81 } else {
82 navigate('/');
83 }
84 return;
85 }
86 if (res?.status === 'expired') {
87 setError(t('sso.sessionExpired'));
88 return;
89 }
90 if (res?.error_msg) {
91 setError(res.error_msg);
92 return;
93 }
94 } catch {
95 // ignore transient errors
96 } finally {
97 setPolling(false);
98 }
99 timer = window.setTimeout(poll, 1500);
100 };
101
102 poll();
103

Callers 1

SSOEntryFunction · 0.70

Calls 1

setErrorFunction · 0.85

Tested by

no test coverage detected