auth.ts
@@ -0,0 +1,32 @@
+ async authorize(credentials) {
+
+ if (!credentials?.username || !credentials?.password || !credentials?.email){
+ return null
+ }
+ const VerfiedUser = await prisma.user.findUnique({
+ where:{
+ username: credentials?.email,
+ }
+ })
+
+ if (VerfiedUser){
+ return VerfiedUser
+ }
+
+ const hash = await bcrypt.hash(credentials?.password ,10)
+
+ const NewUser = await prisma.user.create({
+ data:{
+ username: credentials?.username,
+ password:hash
+ }
+ })
+
+ if (NewUser){
+ return NewUser
+ }
+
+
+ // Return null if user data could not be retrieved
+ return null
+ }
\ No newline at end of file