feat: Projects backend slice — auth, primitives, backend, UI (#3)

This commit is contained in:
2026-07-23 14:09:25 +00:00
parent ab9426b8fc
commit 609badc4ed
32 changed files with 1926 additions and 664 deletions

View File

@@ -36,7 +36,33 @@ const createAuth = (ctx: GenericCtx<DataModel>) =>
export { createAuth };
export interface AuthUserView {
readonly id: string;
readonly name: string;
readonly email: string;
}
/**
* Resolve the authenticated user to the canonical web view. The returned `id`
* is the Convex `identity.tokenIdentifier`, the stable authenticated identity
* used across organization/conversation/Signal ownership. Returns null when no
* identity is present or the Better Auth user row cannot be resolved.
*/
export const getCurrentUser = query({
args: {},
handler: (ctx) => authComponent.safeGetAuthUser(ctx),
handler: async (ctx): Promise<AuthUserView | null> => {
const identity = await ctx.auth.getUserIdentity();
if (!identity) {
return null;
}
const authUser = await authComponent.safeGetAuthUser(ctx);
if (!authUser) {
return null;
}
return {
email: authUser.email,
id: identity.tokenIdentifier,
name: authUser.name,
};
},
});