mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-11-12 07:59:17 +00:00
fix: auth errors
- Fixes Discord not logging in - Also shows the login page but with an error message for future errors
This commit is contained in:
parent
f0cf08f2a4
commit
b2e1ab2d2f
6 changed files with 64 additions and 46 deletions
7
backend/src/app/login/route.ts
Normal file
7
backend/src/app/login/route.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export function GET(req: NextRequest) {
|
||||
const target = new URL("/login", process.env.FRONTEND_URL ?? "http://localhost:5173");
|
||||
target.search = req.nextUrl.search; // keeps ?error=
|
||||
return NextResponse.redirect(target);
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import { prisma } from "@/lib/prisma";
|
|||
|
||||
export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||
adapter: PrismaAdapter(prisma),
|
||||
providers: [Discord, Github({ issuer: "https://github.com/login/oauth" }), Google],
|
||||
providers: [Discord({ issuer: "https://discord.com" }), Github({ issuer: "https://github.com/login/oauth" }), Google],
|
||||
trustHost: true,
|
||||
cookies: {
|
||||
sessionToken: {
|
||||
|
|
@ -26,6 +26,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
|
|||
strategy: "database",
|
||||
maxAge: 30 * 24 * 60 * 60,
|
||||
},
|
||||
pages: { signIn: "/login", error: "/login" },
|
||||
callbacks: {
|
||||
async signIn({ user }) {
|
||||
const blacklist = process.env.BLACKLISTED_EMAILS ? process.env.BLACKLISTED_EMAILS.split(",").map((item) => item.trim().toLowerCase()) : [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue