ahaan
ahaan
Explore posts from servers
TTCTheo's Typesafe Cult
Created by ahaan on 4/20/2024 in #questions
need help with uploadThing SSR plugin
dude
3 replies
TTCTheo's Typesafe Cult
Created by ahaan on 4/20/2024 in #questions
need help with uploadThing SSR plugin
Someone please answer
3 replies
CCConvex Community
Created by ahaan on 3/9/2024 in #general
i am having an issue, this didn't occur
never mind i found the issue
5 replies
CCConvex Community
Created by ahaan on 3/9/2024 in #general
i am having an issue, this didn't occur
// addOrgIdToUser is run as soon as organizationMembership.created is recieved from clerk webhook
export const addOrgIdToUser = internalMutation({
args: {
tokenIdentifier: v.string(),
orgId: v.string()
},
async handler(ctx, args) {
// const user = await getUser(ctx, args.tokenIdentifier);
const identity = await ctx.auth.getUserIdentity();
console.log("getUserIdentity during addOrgIdToUser", args, identity);

if (!identity) {
throw new ConvexError("Unauthenticated call to mutation");
}
const user = await ctx.db
.query("users")
.withIndex("by_tokenIdentifier", (q) =>
q.eq("tokenIdentifier", identity.tokenIdentifier)
)
.first();

if (!user) {
throw new ConvexError("User not found");
}

await ctx.db.patch(user._id, {
orgIds: [...user.orgIds, args.orgId],
});
},
});
// addOrgIdToUser is run as soon as organizationMembership.created is recieved from clerk webhook
export const addOrgIdToUser = internalMutation({
args: {
tokenIdentifier: v.string(),
orgId: v.string()
},
async handler(ctx, args) {
// const user = await getUser(ctx, args.tokenIdentifier);
const identity = await ctx.auth.getUserIdentity();
console.log("getUserIdentity during addOrgIdToUser", args, identity);

if (!identity) {
throw new ConvexError("Unauthenticated call to mutation");
}
const user = await ctx.db
.query("users")
.withIndex("by_tokenIdentifier", (q) =>
q.eq("tokenIdentifier", identity.tokenIdentifier)
)
.first();

if (!user) {
throw new ConvexError("User not found");
}

await ctx.db.patch(user._id, {
orgIds: [...user.orgIds, args.orgId],
});
},
});
5 replies
CCConvex Community
Created by ahaan on 3/9/2024 in #general
i am having an issue, this didn't occur
but the issue is await ctx.auth.getUserIdentity() returns null
5 replies
CCConvex Community
Created by ahaan on 3/9/2024 in #general
i am having an issue, this didn't occur
upon recieving the data, i first check the identity of the existing user before adding him to the organization
5 replies
CCConvex Community
Created by ahaan on 3/9/2024 in #general
i am having an issue, this didn't occur
so I am following @Web Dev Cody tutorial for file storage. As I create new organization in clerk, it uses webhook to send organization_creation data to convex
5 replies
CCConvex Community
Created by ahaan on 2/29/2024 in #general
```const identity = await ctx.auth.
I can't believe I forgot to run the command
34 replies
CCConvex Community
Created by ahaan on 2/29/2024 in #general
```const identity = await ctx.auth.
okay I really feel embarrassed to say this, but I hadn't run the npx convex dev command. Now that I run it, its working totally fine. Sorry mate for troubling you and thank you very much for helping me
34 replies
CCConvex Community
Created by ahaan on 2/29/2024 in #general
```const identity = await ctx.auth.
i just did that and no error pops up or no identity is being logged
34 replies
CCConvex Community
Created by ahaan on 2/29/2024 in #general
```const identity = await ctx.auth.
34 replies
CCConvex Community
Created by ahaan on 2/29/2024 in #general
```const identity = await ctx.auth.
here is the entire code
import { ConvexError, v } from "convex/values";
import { mutation, query } from "./_generated/server";

export const createFile = mutation({
args: {
name: v.string(),
},
async handler(ctx, args) {
const identity = await ctx.auth.getUserIdentity();
console.log("Identity", identity);
if (!identity) {
throw new Error("Unauthenticated call to mutation");
}

await ctx.db.insert("files", {
name: args.name,
});
},
});

export const getFiles = query({
args: {},
async handler(ctx, args) {
return await ctx.db.query("files").collect();
},
});
import { ConvexError, v } from "convex/values";
import { mutation, query } from "./_generated/server";

export const createFile = mutation({
args: {
name: v.string(),
},
async handler(ctx, args) {
const identity = await ctx.auth.getUserIdentity();
console.log("Identity", identity);
if (!identity) {
throw new Error("Unauthenticated call to mutation");
}

await ctx.db.insert("files", {
name: args.name,
});
},
});

export const getFiles = query({
args: {},
async handler(ctx, args) {
return await ctx.db.query("files").collect();
},
});
34 replies
CCConvex Community
Created by ahaan on 2/29/2024 in #general
```const identity = await ctx.auth.
it doesn't print anything at all
34 replies
CCConvex Community
Created by ahaan on 2/29/2024 in #general
```const identity = await ctx.auth.
yeah I am not logged in, let me record a small clip
34 replies
CCConvex Community
Created by ahaan on 2/29/2024 in #general
```const identity = await ctx.auth.
No description
34 replies
CCConvex Community
Created by ahaan on 2/29/2024 in #general
```const identity = await ctx.auth.
oh right you didn't do the null part. Actually, first I went with what you wrote, then since it didn't work, I went to convex docs and tried going through stuff and found the null part, yet it doesn't work
34 replies
CCConvex Community
Created by ahaan on 2/29/2024 in #general
```const identity = await ctx.auth.
@Web Dev Cody mate i follow the exact procedure as you do, but its not producing same result
34 replies
CCConvex Community
Created by ahaan on 2/29/2024 in #general
```const identity = await ctx.auth.
a little more context:
export const createFile = mutation({
args: {
name: v.string(),
},
async handler(ctx, args) {
const identity = await ctx.auth.getUserIdentity();
if (identity === null) {
throw new Error("Unauthenticated call to mutation");
}

await ctx.db.insert("files", {
name: args.name,
});
},
});
export const createFile = mutation({
args: {
name: v.string(),
},
async handler(ctx, args) {
const identity = await ctx.auth.getUserIdentity();
if (identity === null) {
throw new Error("Unauthenticated call to mutation");
}

await ctx.db.insert("files", {
name: args.name,
});
},
});
34 replies