Skip to content
Snippets Groups Projects
Commit d032c0c7 authored by Yusuf Akgül's avatar Yusuf Akgül :hatching_chick:
Browse files

beg auth change

parent e627e255
No related branches found
No related tags found
1 merge request!19Feat.auth fixes
import { env } from "@/env.mjs"
import { calculateOffset, getImageURL } from "@/lib/utils"
import { IAuth, IGame } from "@/types/igdb-types"
const TWITCH_AUTH_BASE_URL = process.env.TWITCH_AUTH_BASE_URL ?? ''
const IGDB_BASE_URL = process.env.IGDB_BASE_URL ?? ''
const TWITCH_AUTH_BASE_URL = env.TWITCH_AUTH_BASE_URL ?? ''
const IGDB_BASE_URL = env.IGDB_BASE_URL ?? ''
const CLIENT_ID = process.env.TWITCH_CLIENT_ID ?? ''
const CLIENT_SECRET = process.env.TWITCH_CLIENT_SECRET ?? ''
const CLIENT_ID = env.TWITCH_CLIENT_ID ?? ''
const CLIENT_SECRET = env.TWITCH_CLIENT_SECRET ?? ''
const limit = 100
......
import { env } from "@/env.mjs"
import { ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
......@@ -6,10 +7,9 @@ export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
const IGDB_IMG_BASE_URL = process.env.IGDB_IMG_BASE_URL ?? ''
// changes the default size of the image to be fetched
export function getImageURL(hashId: string, size: string): string {
const IGDB_IMG_BASE_URL = env.IGDB_IMG_BASE_URL ?? ''
return `${IGDB_IMG_BASE_URL}/t_${size}/${hashId}.jpg`
}
......
import * as z from "zod"
export const userAuthSchema = z.object({
username: z.string().min(3).max(15),
email: z.string().email(),
password: z.string().min(6).max(18),
})
\ No newline at end of file
import "./env.mjs"
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
images: {
unoptimized: true,
domains: ["images.igdb.com"]
}
}
module.exports = nextConfig
export default nextConfig
\ No newline at end of file
......@@ -8,6 +8,8 @@
"name": "project_ss23_gameunity",
"version": "0.2.0",
"dependencies": {
"@auth/prisma-adapter": "^1.0.0",
"@hookform/resolvers": "^3.1.0",
"@prisma/client": "^4.15.0",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-label": "^2.0.2",
......@@ -15,6 +17,7 @@
"@radix-ui/react-select": "^1.2.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.4",
"@t3-oss/env-nextjs": "^0.4.0",
"@tanstack/react-query": "^4.29.12",
"bcrypt": "^5.1.0",
"class-variance-authority": "^0.6.0",
......@@ -25,9 +28,11 @@
"next-themes": "^0.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.44.3",
"react-infinite-scroll-component": "^6.1.0",
"tailwind-merge": "^1.12.0",
"tailwindcss-animate": "^1.0.5"
"tailwindcss-animate": "^1.0.5",
"zod": "^3.21.4"
},
"devDependencies": {
"@tanstack/eslint-plugin-query": "^4.29.9",
......@@ -55,6 +60,58 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/@auth/core": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@auth/core/-/core-0.8.1.tgz",
"integrity": "sha512-WudBmZudZ/cvykxHV5hIwrYsd7AlETQ535O7w3sSiiumT28+U9GvBb8oSRtfzxpW9rym3lAdfeTJqGA8U4FecQ==",
"dependencies": {
"@panva/hkdf": "^1.0.4",
"cookie": "0.5.0",
"jose": "^4.11.1",
"oauth4webapi": "^2.0.6",
"preact": "10.11.3",
"preact-render-to-string": "5.2.3"
},
"peerDependencies": {
"nodemailer": "^6.8.0"
},
"peerDependenciesMeta": {
"nodemailer": {
"optional": true
}
}
},
"node_modules/@auth/core/node_modules/preact": {
"version": "10.11.3",
"resolved": "https://registry.npmjs.org/preact/-/preact-10.11.3.tgz",
"integrity": "sha512-eY93IVpod/zG3uMF22Unl8h9KkrcKIRs2EGar8hwLZZDU1lkjph303V9HZBwufh2s736U6VXuhD109LYqPoffg==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/preact"
}
},
"node_modules/@auth/core/node_modules/preact-render-to-string": {
"version": "5.2.3",
"resolved": "https://registry.npmjs.org/preact-render-to-string/-/preact-render-to-string-5.2.3.tgz",
"integrity": "sha512-aPDxUn5o3GhWdtJtW0svRC2SS/l8D9MAgo2+AWml+BhDImb27ALf04Q2d+AHqUUOc6RdSXFIBVa2gxzgMKgtZA==",
"dependencies": {
"pretty-format": "^3.8.0"
},
"peerDependencies": {
"preact": ">=10"
}
},
"node_modules/@auth/prisma-adapter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@auth/prisma-adapter/-/prisma-adapter-1.0.0.tgz",
"integrity": "sha512-+x+s5dgpNmqrcQC2ZRAXZIM6yhkWP/EXjIUgqUyMepLiX1OHi2AXIUAAbXsW4oG9OpYr/rvPIzPBpuGt6sPFwQ==",
"dependencies": {
"@auth/core": "0.8.1"
},
"peerDependencies": {
"@prisma/client": ">=2.26.0 || >=3 || >=4"
}
},
"node_modules/@babel/runtime": {
"version": "7.21.5",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.5.tgz",
......@@ -147,6 +204,14 @@
"react-dom": ">=16.8.0"
}
},
"node_modules/@hookform/resolvers": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@hookform/resolvers/-/resolvers-3.1.0.tgz",
"integrity": "sha512-z0A8K+Nxq+f83Whm/ajlwE6VtQlp/yPHZnXw7XWVPIGm1Vx0QV8KThU3BpbBRfAZ7/dYqCKKBNnQh85BkmBKkA==",
"peerDependencies": {
"react-hook-form": "^7.0.0"
}
},
"node_modules/@humanwhocodes/config-array": {
"version": "0.11.8",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz",
......@@ -1210,6 +1275,27 @@
"tslib": "^2.4.0"
}
},
"node_modules/@t3-oss/env-core": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/@t3-oss/env-core/-/env-core-0.4.0.tgz",
"integrity": "sha512-6JlMp0Vru15q/axHzBKsQQjiyGS6k+EsZBY1iErGVmOGzNSoVluBahnYFP7tEkwZ7KoRgSq4NRIc1Ez7SVYuxQ==",
"peerDependencies": {
"typescript": ">=4.7.2",
"zod": "^3.0.0"
}
},
"node_modules/@t3-oss/env-nextjs": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/@t3-oss/env-nextjs/-/env-nextjs-0.4.0.tgz",
"integrity": "sha512-K1u2i+S/uEhjfg++FqWlOzS6x237EARRbWGowH2MkDkFu2q7ZJSiJBJT8e47L7NHWH5IyZrTCM6BdOxyWEnQuQ==",
"dependencies": {
"@t3-oss/env-core": "0.4.0"
},
"peerDependencies": {
"typescript": ">=4.7.2",
"zod": "^3.0.0"
}
},
"node_modules/@tanstack/eslint-plugin-query": {
"version": "4.29.9",
"resolved": "https://registry.npmjs.org/@tanstack/eslint-plugin-query/-/eslint-plugin-query-4.29.9.tgz",
......@@ -4341,6 +4427,14 @@
"resolved": "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz",
"integrity": "sha512-a5ERWK1kh38ExDEfoO6qUHJb32rd7aYmPHuyCu3Fta/cnICvYmgd2uhuKXvPD+PXB+gCEYYEaQdIRAjCOwAKNA=="
},
"node_modules/oauth4webapi": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/oauth4webapi/-/oauth4webapi-2.3.0.tgz",
"integrity": "sha512-JGkb5doGrwzVDuHwgrR4nHJayzN4h59VCed6EW8Tql6iHDfZIabCJvg6wtbn5q6pyB2hZruI3b77Nudvq7NmvA==",
"funding": {
"url": "https://github.com/sponsors/panva"
}
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
......@@ -4909,6 +5003,21 @@
"react": "^18.2.0"
}
},
"node_modules/react-hook-form": {
"version": "7.44.3",
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.44.3.tgz",
"integrity": "sha512-/tHId6p2ViAka1wECMw8FEPn/oz/w226zehHrJyQ1oIzCBNMIJCaj6ZkQcv+MjDxYh9MWR7RQic7Qqwe4a5nkw==",
"engines": {
"node": ">=12.22.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/react-hook-form"
},
"peerDependencies": {
"react": "^16.8.0 || ^17 || ^18"
}
},
"node_modules/react-infinite-scroll-component": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/react-infinite-scroll-component/-/react-infinite-scroll-component-6.1.0.tgz",
......@@ -5818,7 +5927,6 @@
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz",
"integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==",
"devOptional": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
......
......@@ -10,15 +10,53 @@ datasource db {
url = env("DATABASE_URL")
}
model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String? @db.Text
access_token String? @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
session_state String?
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
refresh_token_expires_in Int?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@map(name: "accounts")
}
model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map(name: "sessions")
}
model User {
id Int @id @default(autoincrement())
userName String? @unique
name String? @default("u ${id}")
id String @id @default(cuid())
name String?
username String? @unique @map("username")
email String? @unique
password String
emailVerified DateTime?
image String?
createdAt DateTime @default(now())
password String
image String?
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
accounts Account[]
sessions Session[]
Post Post[]
Comment Comment[]
......@@ -28,46 +66,67 @@ model User {
following Follows[] @relation("following")
}
model VerificationToken {
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
@@map(name: "verification_tokens")
}
model Follows {
follower User @relation("following", fields: [followerId], references: [id])
followerId Int
followerId String
following User @relation("follower", fields: [followingId], references: [id])
followingId Int
followingId String
createdAt DateTime @default(now())
@@id([followerId, followingId])
@@map(name: "follows")
}
model Post {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
id String @id @default(cuid())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
userId String
content String
likeCount Int? @default(0)
gameId Int?
published Boolean @default(false)
userId Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
Comment Comment[]
Like Like[]
@@map(name: "posts")
}
model Like {
id Int @id @default(autoincrement())
postId Int
userId Int
id String @id @default(cuid())
postId String
commentId String?
userId String
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
comment Comment? @relation(fields: [commentId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map(name: "likes")
}
model Comment {
id Int @id @default(autoincrement())
id String @id @default(cuid())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
message String
postId Int
userId Int
createdAt DateTime @default(now())
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
likeCount Int? @default(0)
postId String
userId String
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
Like Like[]
@@map(name: "comments")
}
......@@ -27,7 +27,8 @@
"@/*": [
"./*"
]
}
},
"strictNullChecks": true
},
"include": [
"next-env.d.ts",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment