EMILIANOME
Convex Community16mo ago
13 replies
EMILIANOM

Convex + Lucia auth + Svelte | Help

Hello i was able to integrate Lucia with convex (thanks to @v and his repo https://github.com/vynxc/lucia-svelte-convex-demo)

Now I'm trying to write queries that filter by auth user id, to show only those rows the user owns.

import { queryWithAuth } from './auth/withAuth';

export const get = queryWithAuth({
    args: {},
    handler: async (ctx) => {
        const identity = ctx.userSessionContext?.user;
        if (!identity) {
            throw new Error('Not authenticated');
        }
        console.log(identity);

        const tasks = await ctx.db
            .query('tasks')
            // .filter((task) => task.userId === identity._id)
            .collect();
        return tasks.map((task) => ({ ...task, assigner: 'tom' }));
    }
});


Identity is null, even if I'm logged in, can anyone check my implementation and help me with some suggestions

Thanks everyone

Full code: https://github.com/emilianocalzada/convex-lucia-svelte
GitHub
Contribute to emilianocalzada/convex-lucia-svelte development by creating an account on GitHub.
GitHub - emilianocalzada/convex-lucia-svelte
Was this page helpful?