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

Function handleVerify

frontend/src/pages/VerifyEmail.tsx:36–67  ·  view source on GitHub ↗
(tokenToUse: string)

Source from the content-addressed store, hash-verified

34 }, [user, navigate]);
35
36 const handleVerify = async (tokenToUse: string) => {
37 if (!tokenToUse || tokenToUse.length < 6) return;
38
39 setLoading(true);
40 setStatus('verifying');
41 setError('');
42
43 try {
44 const res = await authApi.verifyEmail(tokenToUse);
45 setStatus('success');
46 setMessage(isChinese ? '邮箱验证成功!' : 'Email verified successfully!');
47
48 // Auto-login with the returned token
49 if (res.access_token && res.user) {
50 setAuth(res.user, res.access_token);
51
52 // Redirect based on needs_company_setup
53 setTimeout(() => {
54 if (res.needs_company_setup) {
55 navigate('/setup-company');
56 } else {
57 navigate('/');
58 }
59 }, 1500); // Short delay to show success message
60 }
61 } catch (err: any) {
62 setStatus('error');
63 setMessage(err.message || (isChinese ? '验证失败,请检查验证码是否正确' : 'Verification failed, please check the code'));
64 } finally {
65 setLoading(false);
66 }
67 };
68
69 // Auto-verify if token is in URL
70 useEffect(() => {

Callers 1

VerifyEmailFunction · 0.85

Calls 1

setErrorFunction · 0.85

Tested by

no test coverage detected