(email: string, password: string)
| 57 | * 登录:返回 true 表示成功(后端会写入 Cookie) |
| 58 | */ |
| 59 | export async function loginUser(email: string, password: string): Promise<boolean> { |
| 60 | const nonce = await fetchLoginNonce(email); |
| 61 | const passHash = await sha256(password); |
| 62 | const passHmac = await hmac256(passHash, nonce); |
| 63 | const url = `/login/?email=${encodeURIComponent(email)}&token=${passHmac}`; |
| 64 | const res = await http.get<ApiResp>(url); |
| 65 | return res.status === 200 && (res.data.flags === 1 || res.data.flags === undefined); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * 注册 |
no test coverage detected