We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2eab634 commit c79f0b1Copy full SHA for c79f0b1
convex/myFunctions.ts
@@ -1,6 +1,7 @@
1
import { v } from "convex/values";
2
import { query, mutation, action } from "./_generated/server";
3
import { api } from "./_generated/api";
4
+import { getAuthUserId } from "@convex-dev/auth/server";
5
6
// Write your Convex functions in any file inside this directory (`convex`).
7
// See https://docs.convex.dev/functions for more.
@@ -21,8 +22,10 @@ export const listNumbers = query({
21
22
// Ordered by _creationTime, return most recent
23
.order("desc")
24
.take(args.count);
25
+ const userId = await getAuthUserId(ctx);
26
+ const user = userId === null ? null : await ctx.db.get(userId);
27
return {
- viewer: (await ctx.auth.getUserIdentity())?.name ?? null,
28
+ viewer: user?.email ?? null,
29
numbers: numbers.reverse().map((number) => number.value),
30
};
31
},
0 commit comments