export const { auth, signIn, signOut, store } = convexAuth({
providers: [
Password,
],
callbacks: {
async createOrUpdateUser(ctx, args) {
if (args.existingUserId) {
await ctx.db.patch(args.existingUserId, {
email: args.profile.email,
phone: args.profile.phone,
// Name goes here
});
return args.existingUserId;
} else {
return await ctx.db.insert('users', {
role: 'user',
email: args.profile.email,
// Name goes here
});
}
},
},
session: {
totalDurationMs: 1000 * 60 * 60 * 24 * 30, // 90 days
inactiveDurationMs: 1000 * 60 * 60 * 24 * 7, // 7 days
},
});
export const { auth, signIn, signOut, store } = convexAuth({
providers: [
Password,
],
callbacks: {
async createOrUpdateUser(ctx, args) {
if (args.existingUserId) {
await ctx.db.patch(args.existingUserId, {
email: args.profile.email,
phone: args.profile.phone,
// Name goes here
});
return args.existingUserId;
} else {
return await ctx.db.insert('users', {
role: 'user',
email: args.profile.email,
// Name goes here
});
}
},
},
session: {
totalDurationMs: 1000 * 60 * 60 * 24 * 30, // 90 days
inactiveDurationMs: 1000 * 60 * 60 * 24 * 7, // 7 days
},
});