(e)
| 127 | } |
| 128 | |
| 129 | async function handleSubmit(e) { |
| 130 | if (password.length < 8) { |
| 131 | showInfo('密码长度不得小于 8 位!'); |
| 132 | return; |
| 133 | } |
| 134 | if (password !== password2) { |
| 135 | showInfo('两次输入的密码不一致'); |
| 136 | return; |
| 137 | } |
| 138 | if (username && password) { |
| 139 | if (turnstileEnabled && turnstileToken === '') { |
| 140 | showInfo('请稍后几秒重试,Turnstile 正在检查用户环境!'); |
| 141 | return; |
| 142 | } |
| 143 | setRegisterLoading(true); |
| 144 | try { |
| 145 | if (!affCode) { |
| 146 | affCode = localStorage.getItem('aff'); |
| 147 | } |
| 148 | inputs.aff_code = affCode; |
| 149 | const res = await API.post( |
| 150 | `/api/user/register?turnstile=${turnstileToken}`, |
| 151 | inputs, |
| 152 | ); |
| 153 | const { success, message } = res.data; |
| 154 | if (success) { |
| 155 | navigate('/login'); |
| 156 | showSuccess('注册成功!'); |
| 157 | } else { |
| 158 | showError(message); |
| 159 | } |
| 160 | } catch (error) { |
| 161 | showError('注册失败,请重试'); |
| 162 | } finally { |
| 163 | setRegisterLoading(false); |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | const sendVerificationCode = async () => { |
| 169 | if (inputs.email === '') return; |
nothing calls this directly
no test coverage detected