feat: initial commit - 1000apps SaaS container

This commit is contained in:
Carlos
2026-06-29 08:26:45 +02:00
commit d8fb36e6c3
28 changed files with 3092 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
import NextAuth from "next-auth"
import CredentialsProvider from "next-auth/providers/credentials"
import { PrismaAdapter } from "@next-auth/prisma-adapter"
import { PrismaClient } from "@prisma/client"
import bcrypt from "bcryptjs"
const prisma = new PrismaClient()
export default NextAuth({
adapter: PrismaAdapter(prisma),
providers: [
CredentialsProvider({
name: "Credentials",
credentials: {
username: { label: "Username", type: "text", placeholder: "seu_usuario" },
password: { label: "Password", type: "password" }
},
async authorize(credentials) {
if (!credentials?.username || !credentials?.password) return null
const user = await prisma.user.findUnique({
where: { username: credentials.username }
})
if (user && user.password) {
const isValid = await bcrypt.compare(credentials.password, user.password)
if (isValid) {
return {
id: user.id,
email: user.email,
name: user.name || user.username,
username: user.username
}
}
}
return null
}
})
],
secret: process.env.NEXTAUTH_SECRET,
session: { strategy: "jwt" },
pages: {
signIn: "/signin",
},
callbacks: {
async session({ session, token, user }) {
if (session.user) {
session.user.id = token.sub
}
return session
}
}
})