Sam
Sam
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Sam on 11/15/2023 in #questions
NextAuth + DiscordProvider
I feel like I might be going about my setup wrong, but just wanted to check in. I basically want a bunch of users that are purely based on Discord accounts, and then to use their data for my Discord dashboard. Here is my prisma user schema (rest are default)
model User {
discordId String @id @unique
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
posts Post[]
}
model User {
discordId String @id @unique
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
posts Post[]
}
The error I am getting is
Argument `discordId` is missing.
[next-auth][error][adapter_error_createUser]
https://next-auth.js.org/errors#adapter_error_createuser
Invalid `prisma.user.create()` invocation:

{
data: {
email: undefined,
emailVerified: null,
+ discordId: String
}
}
Argument `discordId` is missing.
[next-auth][error][adapter_error_createUser]
https://next-auth.js.org/errors#adapter_error_createuser
Invalid `prisma.user.create()` invocation:

{
data: {
email: undefined,
emailVerified: null,
+ discordId: String
}
}
But can I disable this somehow?? I am overriding the signIn function so I presumed that would do it:
async signIn({ profile }) {
if (!profile) return false;
const DisP = profile as DiscordProfile;

const user = await Prisma.user.findUnique({
where: { discordId: DisP.id },
});

if (!user) {
console.log("CREATING USER", DisP.id);

await Prisma.user.create({
data: {
discordId: DisP.id,
email: DisP.email,
// Include other properties as needed
},
});
}

return true;
}
}
async signIn({ profile }) {
if (!profile) return false;
const DisP = profile as DiscordProfile;

const user = await Prisma.user.findUnique({
where: { discordId: DisP.id },
});

if (!user) {
console.log("CREATING USER", DisP.id);

await Prisma.user.create({
data: {
discordId: DisP.id,
email: DisP.email,
// Include other properties as needed
},
});
}

return true;
}
}
Any ideas? This setup works fine as the database has the user ID in it fine, but its just that this is now giving me that above error. Plus, is this the best way to handle this? Seems a bit convuluted. Thanks!
28 replies
TTCTheo's Typesafe Cult
Created by Sam on 11/1/2023 in #questions
Dockerized T3 giving prisma connection errors
Hey! So I am running a docker network where I have srv-cap--kobos-db as a ready and availble database used in other applications. But for some reason, on this specific T3 application, I am getting this:
Can't reach database server at `srv-captain--kobos-db`:`3306`

Please make sure your database server is running at `srv-captain--kobos-db`:`3306`.
PrismaClientInitializationError:
Invalid `prisma.folder.findMany()` invocation:


Can't reach database server at `srv-captain--kobos-db`:`3306`

Please make sure your database server is running at `srv-captain--kobos-db`:`3306`.
at wn.handleRequestError (/app/node_modules/@prisma/client/runtime/library.js:123:7003)
Can't reach database server at `srv-captain--kobos-db`:`3306`

Please make sure your database server is running at `srv-captain--kobos-db`:`3306`.
PrismaClientInitializationError:
Invalid `prisma.folder.findMany()` invocation:


Can't reach database server at `srv-captain--kobos-db`:`3306`

Please make sure your database server is running at `srv-captain--kobos-db`:`3306`.
at wn.handleRequestError (/app/node_modules/@prisma/client/runtime/library.js:123:7003)
Keep in mind, I have tested connecting to this from other apps and it works. It's just T3 specifically that's failing. I'm using the Dockerfile found here https://create.t3.gg/en/deployment/docker and I am using CapRover as my PaaS where I am passing the database URL in the env. Any ideas? Much appreciated!
4 replies