#How to update identity.name

4 messages · Page 1 of 1 (latest)

frigid radish
#

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?

hushed topaz
#

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

Mutations insert, update and remove data from the database, check authentication