start working on next auth
This commit is contained in:
parent
410c2e1cc5
commit
67a0dccb95
@ -1,12 +1,15 @@
|
||||
import "../styles/globals.css";
|
||||
|
||||
import { NextUIProvider } from "@nextui-org/react";
|
||||
import { SessionProvider } from "next-auth/react";
|
||||
|
||||
function MyApp({ Component, pageProps }) {
|
||||
function MyApp({ Component, pageProps: { session, ...pageProps } }) {
|
||||
return (
|
||||
<NextUIProvider>
|
||||
<Component {...pageProps} />
|
||||
</NextUIProvider>
|
||||
<SessionProvider session={session}>
|
||||
<NextUIProvider>
|
||||
<Component {...pageProps} />
|
||||
</NextUIProvider>
|
||||
</SessionProvider>
|
||||
);
|
||||
}
|
||||
|
||||
|
26
src/pages/api/auth/[...nextauth].js
Normal file
26
src/pages/api/auth/[...nextauth].js
Normal file
@ -0,0 +1,26 @@
|
||||
import NextAuth from "next-auth";
|
||||
import CredentialsProvider from "next-auth/providers/credentials";
|
||||
|
||||
export const authOptions = {
|
||||
providers: [
|
||||
CredentialsProvider({
|
||||
name: "Credentials",
|
||||
credentials: {
|
||||
username: { label: "Username", type: "text", placeholder: "admin" },
|
||||
password: { label: "Password", type: "password" },
|
||||
},
|
||||
async authorize(credentials, req) {
|
||||
console.log(credentials);
|
||||
const user = { id: "1", name: "J Smith", email: "admin@example.com" };
|
||||
|
||||
if (user) {
|
||||
return user;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
export default NextAuth(authOptions);
|
Reference in New Issue
Block a user