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
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-argumentsFinal: 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
Yes, I got it. Thank you so much.