(e)
| 45 | } |
| 46 | |
| 47 | async function handleSubmit(e) { |
| 48 | if (password.length < 8) { |
| 49 | showInfo('密码长度不得小于 8 位!'); |
| 50 | return; |
| 51 | } |
| 52 | if (password !== password2) { |
| 53 | showInfo('两次输入的密码不一致'); |
| 54 | return; |
| 55 | } |
| 56 | if (username && password) { |
| 57 | if (turnstileEnabled && turnstileToken === '') { |
| 58 | showInfo('请稍后几秒重试,Turnstile 正在检查用户环境!'); |
| 59 | return; |
| 60 | } |
| 61 | setLoading(true); |
| 62 | if (!affCode) { |
| 63 | affCode = localStorage.getItem('aff'); |
| 64 | } |
| 65 | inputs.aff_code = affCode; |
| 66 | const res = await API.post( |
| 67 | `/api/user/register?turnstile=${turnstileToken}`, |
| 68 | inputs |
| 69 | ); |
| 70 | const { success, message } = res.data; |
| 71 | if (success) { |
| 72 | navigate('/login'); |
| 73 | showSuccess('注册成功!'); |
| 74 | } else { |
| 75 | showError(message); |
| 76 | } |
| 77 | setLoading(false); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | const sendVerificationCode = async () => { |
| 82 | if (inputs.email === '') return; |
nothing calls this directly
no test coverage detected