Miia
Miia
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
@j6rms It ends up fixing it, deleting all dependencies and running an npm upgrade (absolute), basically update all libraries, existing in the project to the latest possible no matter if there are errors or incompatibility, it seems to be a node+nextjs problem and a weird interaction with some method.
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
;D
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
I have tried everything and nothing works, even downloading the t3 template does not work.
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
No description
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
using an https domain does not work either.
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
No description
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
"next": "^13.4.5", "next-auth": "^4.23.0",
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
No description
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
same result
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
nothing
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
No description
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
1s
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
hm
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
it doesn't work either, if I remove the role, in case you had any doubts xD
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
import { PrismaAdapter } from "@next-auth/prisma-adapter";
import { type UserRole } from "@prisma/client";
import { type GetServerSidePropsContext } from "next";
import {
getServerSession,
type DefaultSession,
type NextAuthOptions,
} from "next-auth";
import DiscordProvider from "next-auth/providers/discord";

import { env } from "~/env.mjs";
import { prisma } from "~/server/db";

/**
* Module augmentation for `next-auth` types. Allows us to add custom properties to the `session`
* object and keep type safety.
*
* @see https://next-auth.js.org/getting-started/typescript#module-augmentation
*/
declare module "next-auth" {
interface Session extends DefaultSession {
user: DefaultSession["user"] & {
id: string;
role: UserRole;
};
}

interface User {
role: UserRole;
}
}

/**
* Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
*
* @see https://next-auth.js.org/configuration/options
*/

export const authOptions: NextAuthOptions = {
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
role: user.role,
id: user.id,
},
})
},
providers: [
DiscordProvider({
clientId: env.DISCORD_CLIENT_ID,
clientSecret: env.DISCORD_CLIENT_SECRET,
}),
/**
* ...add more providers here.
*
* Most other providers require a bit more work than the Discord provider. For example, the
* GitHub provider requires you to add the `refresh_token_expires_in` field to the Account
* model. Refer to the NextAuth.js docs for the provider you want to use. Example:
*
* @see https://next-auth.js.org/providers/github
*/
],
adapter: PrismaAdapter(prisma),

debug:true,
};

/**
* Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file.
*
* @see https://next-auth.js.org/configuration/nextjs
*/
export const getServerAuthSession = (ctx: {
req: GetServerSidePropsContext["req"];
res: GetServerSidePropsContext["res"];
}) => {
return getServerSession(ctx.req, ctx.res, authOptions);
};
import { PrismaAdapter } from "@next-auth/prisma-adapter";
import { type UserRole } from "@prisma/client";
import { type GetServerSidePropsContext } from "next";
import {
getServerSession,
type DefaultSession,
type NextAuthOptions,
} from "next-auth";
import DiscordProvider from "next-auth/providers/discord";

import { env } from "~/env.mjs";
import { prisma } from "~/server/db";

/**
* Module augmentation for `next-auth` types. Allows us to add custom properties to the `session`
* object and keep type safety.
*
* @see https://next-auth.js.org/getting-started/typescript#module-augmentation
*/
declare module "next-auth" {
interface Session extends DefaultSession {
user: DefaultSession["user"] & {
id: string;
role: UserRole;
};
}

interface User {
role: UserRole;
}
}

/**
* Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
*
* @see https://next-auth.js.org/configuration/options
*/

export const authOptions: NextAuthOptions = {
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
role: user.role,
id: user.id,
},
})
},
providers: [
DiscordProvider({
clientId: env.DISCORD_CLIENT_ID,
clientSecret: env.DISCORD_CLIENT_SECRET,
}),
/**
* ...add more providers here.
*
* Most other providers require a bit more work than the Discord provider. For example, the
* GitHub provider requires you to add the `refresh_token_expires_in` field to the Account
* model. Refer to the NextAuth.js docs for the provider you want to use. Example:
*
* @see https://next-auth.js.org/providers/github
*/
],
adapter: PrismaAdapter(prisma),

debug:true,
};

/**
* Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file.
*
* @see https://next-auth.js.org/configuration/nextjs
*/
export const getServerAuthSession = (ctx: {
req: GetServerSidePropsContext["req"];
res: GetServerSidePropsContext["res"];
}) => {
return getServerSession(ctx.req, ctx.res, authOptions);
};
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
1s*
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
s
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
No description
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
1s
135 replies
TTCTheo's Typesafe Cult
Created by Miia on 8/30/2023 in #questions
problems with next-auth
nup
135 replies