cps-user3
cps-user314mo ago

How to update identity.name

Hello, I am creating a user table with the code below. export const create = mutation({ args: {}, handler: async (ctx, args) => { const identity = await ctx.auth.getUserIdentity(); if (!identity) { throw new Error("Not authenticated"); } const userId = identity.subject; const userName = identity.name; const user = await ctx.db.insert("users", { userId, userName, }); return user; } }); Is there a way to get a name from the client and update the identity.name with that value?
2 Replies
Indy
Indy14mo ago
identity.name is something the auth provider sets. It's part of the spec for Open ID: https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims If you want to use a different name then you can pass it directly as an argument to your function: https://docs.convex.dev/functions/mutation-functions#mutation-arguments
Final: OpenID Connect Core 1.0 incorporating errata set 2
OpenID Connect Core 1.0 incorporating errata set 2
Mutations | Convex Developer Hub
Mutations insert, update and remove data from the database, check authentication
cps-user3
cps-user3OP14mo ago
Yes, I got it. Thank you so much.

Did you find this page helpful?