DieZitrone
DTDrizzle Team
•Created by DieZitrone on 11/23/2023 in #help
Drizzle with next auth user is undefined
Hey I am using next auth with dirzzle and my user is always undefined on the callback:
What am I doing wrong? Or did I misunderstood something?
import { db } from "@/db";
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import { NextAuthOptions, getServerSession } from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import GithubProvider from "next-auth/providers/github";
import * as dotenv from "dotenv";
import { Adapter } from "next-auth/adapters";
dotenv.config();
export const authOptions: NextAuthOptions = {
secret: process.env.NEXTAUTH_SECRET,
adapter: DrizzleAdapter(db),
session: {
strategy: "jwt",
},
callbacks: {
async jwt({ token, user }) {
console.log("token", token);
console.log("token", user);
return token;
},
async session({ session, user }) {
console.log("session", session);
console.log("session", user);
return session;
},
},
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
}),
GithubProvider({
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
}),
],
pages: {
signIn: "/sign-in",
signOut: "/sign-out",
},
};
export const getAuthSession = () => getServerSession(authOptions);
import { db } from "@/db";
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import { NextAuthOptions, getServerSession } from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import GithubProvider from "next-auth/providers/github";
import * as dotenv from "dotenv";
import { Adapter } from "next-auth/adapters";
dotenv.config();
export const authOptions: NextAuthOptions = {
secret: process.env.NEXTAUTH_SECRET,
adapter: DrizzleAdapter(db),
session: {
strategy: "jwt",
},
callbacks: {
async jwt({ token, user }) {
console.log("token", token);
console.log("token", user);
return token;
},
async session({ session, user }) {
console.log("session", session);
console.log("session", user);
return session;
},
},
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
}),
GithubProvider({
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
}),
],
pages: {
signIn: "/sign-in",
signOut: "/sign-out",
},
};
export const getAuthSession = () => getServerSession(authOptions);
1 replies
DTDrizzle Team
•Created by DieZitrone on 10/23/2023 in #help
postgres error: type "serial" does not exist
I want to migrate my my changes but i get this
error: type "serial" does not exist.
This is my schema:
export const likes = pgTable("likes", {
postId: text("post_id").notNull().primaryKey(),
authorId: integer("author_id"),
});
export const posts = pgTable("post", {
id: serial("id").notNull().primaryKey(),
code: text("content"),
language: text("content"),
likes: integer("likes"),
authorId: integer("author_id")
.notNull()
.references(() => users.id),
});
export const users = pgTable("user", {
id: serial("id").notNull().primaryKey(),
username: text("username").unique(),
name: text("name"),
email: text("email").notNull(),
emailVerified: timestamp("emailVerified", { mode: "date" }),
image: text("image"),
});
export const likes = pgTable("likes", {
postId: text("post_id").notNull().primaryKey(),
authorId: integer("author_id"),
});
export const posts = pgTable("post", {
id: serial("id").notNull().primaryKey(),
code: text("content"),
language: text("content"),
likes: integer("likes"),
authorId: integer("author_id")
.notNull()
.references(() => users.id),
});
export const users = pgTable("user", {
id: serial("id").notNull().primaryKey(),
username: text("username").unique(),
name: text("name"),
email: text("email").notNull(),
emailVerified: timestamp("emailVerified", { mode: "date" }),
image: text("image"),
});
8 replies