aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc/routers
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-03-05 16:30:31 +0000
committerMohamedBassem <me@mbassem.com>2024-03-05 16:30:44 +0000
commit56c5236245359987e7a729979de3892bbee70852 (patch)
treed5acb844b606502263414eff030c3c5708f6e98b /packages/trpc/routers
parent9490a3a616f526ee7b495abab27af111df16bbb4 (diff)
downloadkarakeep-56c5236245359987e7a729979de3892bbee70852.tar.zst
extension: Show who the logged in user is in the extension options
Diffstat (limited to 'packages/trpc/routers')
-rw-r--r--packages/trpc/routers/users.ts18
1 files changed, 17 insertions, 1 deletions
diff --git a/packages/trpc/routers/users.ts b/packages/trpc/routers/users.ts
index b5334f99..efef61af 100644
--- a/packages/trpc/routers/users.ts
+++ b/packages/trpc/routers/users.ts
@@ -1,5 +1,10 @@
import { zSignUpSchema } from "../types/users";
-import { adminProcedure, publicProcedure, router } from "../index";
+import {
+ adminProcedure,
+ authedProcedure,
+ publicProcedure,
+ router,
+} from "../index";
import { SqliteError } from "@hoarder/db";
import { z } from "zod";
import { hashPassword } from "../auth";
@@ -90,4 +95,15 @@ export const usersAppRouter = router({
throw new TRPCError({ code: "NOT_FOUND" });
}
}),
+ whoami: authedProcedure
+ .output(
+ z.object({
+ id: z.string(),
+ name: z.string(),
+ email: z.string(),
+ }),
+ )
+ .query(async ({ ctx }) => {
+ return { id: ctx.user.id, name: ctx.user.name, email: ctx.user.email };
+ }),
});