21 lines
576 B
TypeScript
21 lines
576 B
TypeScript
import { convexAuth, getAuthUserId } from '@convex-dev/auth/server';
|
|
import { query } from './_generated/server';
|
|
import Password from './CustomPassword';
|
|
|
|
export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
|
|
providers: [Password],
|
|
});
|
|
|
|
export const getUser = query(async (ctx) => {
|
|
const userId = await getAuthUserId(ctx);
|
|
if (!userId) return null;
|
|
const user = await ctx.db.get(userId);
|
|
if (!user) return null;
|
|
return {
|
|
id: user._id,
|
|
email: user.email ?? null,
|
|
name: user.name ?? null,
|
|
image: user.image ?? null,
|
|
}
|
|
});
|