feat: add USER_ROLES && admin pages search when keybord enter && auto trim (#348)

* feat: add USER_ROLES

* feat: admin pages search when keybord enter && auto trim

* feat: update version to v0.6.0
This commit is contained in:
Dream Hunter
2024-07-14 19:57:43 +08:00
committed by GitHub
parent 26ccfdd6e0
commit 75c48beb3b
25 changed files with 370 additions and 49 deletions

View File

@@ -2,8 +2,9 @@ import { Context } from "hono";
import { HonoCustomType } from "../types";
import { UserSettings } from "../models";
import { getJsonSetting } from "../utils"
import { getJsonSetting, getUserRoles } from "../utils"
import { CONSTANTS } from "../constants";
import { commonGetUserRole } from "../common";
export default {
openSettings: async (c: Context<HonoCustomType>) => {
@@ -19,10 +20,14 @@ export default {
// check if user exists
const db_user_id = await c.env.DB.prepare(
`SELECT id FROM users where id = ?`
).bind(user.user_id).first("id");
).bind(user.user_id).first<number | undefined | null>("id");
if (!db_user_id) {
return c.text("User not found", 400);
}
return c.json(user);
const user_role = await commonGetUserRole(c, db_user_id);
return c.json({
...user,
user_role: user_role
});
},
}