From 67a0dccb9564d1f5da40e57f281a43d5fda7272f Mon Sep 17 00:00:00 2001
From: Liam <67254223+RealFascinated@users.noreply.github.com>
Date: Sun, 13 Nov 2022 20:20:16 +0000
Subject: [PATCH] start working on next auth
---
src/pages/_app.js | 11 +++++++----
src/pages/api/auth/[...nextauth].js | 26 ++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 4 deletions(-)
create mode 100644 src/pages/api/auth/[...nextauth].js
diff --git a/src/pages/_app.js b/src/pages/_app.js
index 8a67468..5744c81 100644
--- a/src/pages/_app.js
+++ b/src/pages/_app.js
@@ -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 (
-
-
-
+
+
+
+
+
);
}
diff --git a/src/pages/api/auth/[...nextauth].js b/src/pages/api/auth/[...nextauth].js
new file mode 100644
index 0000000..f3f4af6
--- /dev/null
+++ b/src/pages/api/auth/[...nextauth].js
@@ -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);