ship 1.4.28:Arcrun@19c82df
This commit is contained in:
@@ -12923,6 +12923,25 @@ portalRouter.post(
|
||||
return c.json({ success: true, record_id: recordId, email, role: "admin" });
|
||||
})
|
||||
);
|
||||
portalRouter.post(
|
||||
"/portal/admin/recover-password",
|
||||
(c) => run(c, async () => {
|
||||
const consoleOk = await validateConsoleSession(c.env, c.req.header("authorization"));
|
||||
if (!consoleOk) return c.json({ error: "\u9700\u8981 console owner session\uFF08\u5148\u767B\u5165 /console\uFF09" }, 401);
|
||||
const body = await c.req.json().catch(() => null);
|
||||
const email = String(body?.email ?? "").trim().toLowerCase();
|
||||
if (!isValidEmail(email)) return c.json({ error: "email \u683C\u5F0F\u4E0D\u6B63\u78BA" }, 400);
|
||||
const recordId = await findUserRecordId(c.env, email);
|
||||
const rec = recordId ? await getRecordById(c.env, recordId) : null;
|
||||
if (!recordId || !rec) return c.json({ error: `\u627E\u4E0D\u5230 email\uFF1D${email} \u7684 portal \u5E33\u865F` }, 404);
|
||||
const password = generatePassword();
|
||||
await patchRecordValues(c.env, recordId, {
|
||||
password_hash: await hashPassword2(password),
|
||||
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
||||
});
|
||||
return c.json({ success: true, email, password });
|
||||
})
|
||||
);
|
||||
portalRouter.get(
|
||||
"/portal/admin/users",
|
||||
(c) => run(c, async () => {
|
||||
|
||||
Reference in New Issue
Block a user