From 7adb71028981c16b1dcc4a3564076b4cf847bb23 Mon Sep 17 00:00:00 2001 From: rgerum <14153051+rgerum@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:59:39 -0400 Subject: [PATCH] admin: allow to search by discord id --- src/app/admin/users/[user_id]/page.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/admin/users/[user_id]/page.jsx b/src/app/admin/users/[user_id]/page.jsx index 253d9539..c37f4dc3 100644 --- a/src/app/admin/users/[user_id]/page.jsx +++ b/src/app/admin/users/[user_id]/page.jsx @@ -5,8 +5,12 @@ import { sql } from "@/lib/db"; async function user_properties(id) { const isNumeric = (value) => value.length !== 0 && [...value].every((c) => c >= "0" && c <= "9"); - if (isNumeric(id)) + if (isNumeric(id)) { + // if it is a discord ID + if(id.length >= 10) + return (await sql`SELECT * FROM users WHERE id = (SELECT "userId" FROM accounts where "providerAccountId" = ${id})`)[0]; return (await sql`SELECT * FROM "users" WHERE id = ${id} LIMIT 1;`)[0]; + } else return (await sql`SELECT * FROM "users" WHERE REPLACE(name, ' ', '') = ${id.replace("%20", "")} LIMIT 1;`)[0]; }