-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth): setup nextauth, register with credentials
- Loading branch information
1 parent
8217a50
commit 3a235c8
Showing
8 changed files
with
635 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
DATABASE_URL="mongodb+srv://<username>:<password>@cluster0.<cluster_id>.mongodb.net/<db_env>" | ||
DATABASE_URL="mongodb+srv://<username>:<password>@cluster0.<cluster_id>.mongodb.net/<db_env>" | ||
NEXTAUTH_SECRET= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
- Zustand | ||
- React-hook-form | ||
- Prisma | ||
- Next/auth | ||
|
||
## Installation | ||
``` | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { NextResponse } from "next/server"; | ||
import bcrypt from "bcrypt"; | ||
|
||
import prisma from "@/app/libs/prismadb"; | ||
|
||
export async function POST(request: Request) { | ||
const body = await request.json(); | ||
const { email, name, password } = body; | ||
|
||
const hashedPassword = await bcrypt.hash(password, 12); | ||
|
||
const user = await prisma.user.create({ | ||
data: { | ||
email, | ||
name, | ||
hashedPassword, | ||
}, | ||
}); | ||
|
||
return NextResponse.json(user); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { PrismaClient } from "@prisma/client"; | ||
|
||
declare global { | ||
var prisma: PrismaClient | undefined; | ||
} | ||
|
||
const client = globalThis.prisma || new PrismaClient(); | ||
|
||
if (process.env.NODE_ENV !== "production") { | ||
globalThis.prisma = client; | ||
} | ||
|
||
export default client; |
Oops, something went wrong.