Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit 8841b8c

Browse files
Manuel Proßizzyyhh
authored andcommitted
feat(web): add basic setup for credentials provider
1 parent 3384906 commit 8841b8c

File tree

1 file changed

+19
-0
lines changed
  • web/src/app/api/auth/[...nextauth]

1 file changed

+19
-0
lines changed

web/src/app/api/auth/[...nextauth]/route.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import GithubProvider from "next-auth/providers/github";
2+
import CredentialsProvider from "next-auth/providers/credentials";
23
import NextAuth from "next-auth/next";
34

45
const authOptions = {
@@ -7,6 +8,24 @@ const authOptions = {
78
clientId: process.env.GITHUB_ID ?? "",
89
clientSecret: process.env.GITHUB_SECRET ?? "",
910
}),
11+
CredentialsProvider({
12+
name: "Credentials",
13+
credentials: {
14+
username: { label: "Username", type: "text", placeholder: "jsmith" },
15+
password: { label: "Password", type: "password" },
16+
},
17+
async authorize(credentials) {
18+
const res = await fetch("/your/endpoint", {
19+
method: "POST",
20+
body: JSON.stringify(credentials),
21+
headers: { "Content-Type": "application/json" },
22+
});
23+
const user = await res.json();
24+
25+
if (res.ok && user) return user;
26+
else return null;
27+
},
28+
}),
1029
],
1130
};
1231

0 commit comments

Comments
 (0)