Skip to content

Commit

Permalink
account
Browse files Browse the repository at this point in the history
  • Loading branch information
chibat committed Feb 13, 2024
1 parent 27e847f commit 86eff69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion routes/users/[userId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import UserPosts from "~/islands/UserPosts.tsx";
export default defineRoute(async (req, ctx) => {
const session = await getSession(req);
const authUrl = session ? undefined : getAuthUrl(req.url);
const pageUser = await selectUser(Number(ctx.params.userId));
const pageUser = await selectUser(ctx.params.userId);
if (!pageUser) {
return ctx.renderNotFound();
}
Expand Down
14 changes: 7 additions & 7 deletions server/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ export async function deleteUser(
}
}

export async function selectUser(userId: number) {
const { data, error } = await supabase.from("app_user").select(
export async function selectUser(userKey: string) {
const id = Number(userKey);
const select = supabase.from("app_user").select(
"id,name,picture,notification",
).eq(
"id",
userId,
)
.maybeSingle();
);
const { data, error } =
await (isNaN(id) ? select.eq("account", userKey) : select.eq("id", id))
.maybeSingle();
if (error) {
throw error;
}
Expand Down

0 comments on commit 86eff69

Please sign in to comment.