mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
adding clerk authentication
This commit is contained in:
@@ -1 +1,4 @@
|
||||
AUTH_SECRET="a73X70xifFO5+V9oQ+/NKDDTgA4dsuWWxvFX6T1v1ns=" # Added by `npx auth`. Read more: https://cli.authjs.dev
|
||||
|
||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_bmV3LXN3YW4tMjguY2xlcmsuYWNjb3VudHMuZGV2JA
|
||||
CLERK_SECRET_KEY=••••••••••••••••••••••••••••••••••••••••••••••••••
|
||||
274
package-lock.json
generated
274
package-lock.json
generated
@@ -8,6 +8,7 @@
|
||||
"name": "balistics-builder",
|
||||
"version": "0.2.0",
|
||||
"dependencies": {
|
||||
"@clerk/nextjs": "^6.10.0",
|
||||
"@emotion/react": "^11.13.5",
|
||||
"@emotion/styled": "^11.13.5",
|
||||
"@headlessui/react": "^2.2.0",
|
||||
@@ -296,6 +297,138 @@
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@clerk/backend": {
|
||||
"version": "1.23.5",
|
||||
"resolved": "https://registry.npmjs.org/@clerk/backend/-/backend-1.23.5.tgz",
|
||||
"integrity": "sha512-3HVYa1qiOIny+45V5UBwVfMRZDXl4deVfjFMPvmAYbAiNqY39TgtHdMnDsGZF09eOUnnpTu/6jV4doPLdmWHWg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@clerk/shared": "^2.20.12",
|
||||
"@clerk/types": "^4.42.0",
|
||||
"cookie": "1.0.2",
|
||||
"snakecase-keys": "8.0.1",
|
||||
"tslib": "2.4.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.17.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@clerk/backend/node_modules/cookie": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz",
|
||||
"integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@clerk/backend/node_modules/tslib": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz",
|
||||
"integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/@clerk/clerk-react": {
|
||||
"version": "5.22.4",
|
||||
"resolved": "https://registry.npmjs.org/@clerk/clerk-react/-/clerk-react-5.22.4.tgz",
|
||||
"integrity": "sha512-uDUczpvP4PgTp3mDEd+ITka4yVdQUrU3pVxWBb4Q81XGHDF9GCPb5XbDjV0iR8gB0txI9xopXwUez5/T4VZRVA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@clerk/shared": "^2.20.12",
|
||||
"@clerk/types": "^4.42.0",
|
||||
"tslib": "2.4.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.17.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^18.0.0 || ^19.0.0 || ^19.0.0-0",
|
||||
"react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@clerk/clerk-react/node_modules/tslib": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz",
|
||||
"integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/@clerk/nextjs": {
|
||||
"version": "6.10.0",
|
||||
"resolved": "https://registry.npmjs.org/@clerk/nextjs/-/nextjs-6.10.0.tgz",
|
||||
"integrity": "sha512-s6srzAxMStgP2UBsgSNyWECt+c7s/Zq+/qLAk05O17HXTjb1ydmK/cGxJI5JS9MYv49Z88Ct3AL9CiUbGv/0bA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@clerk/backend": "^1.23.5",
|
||||
"@clerk/clerk-react": "^5.22.4",
|
||||
"@clerk/shared": "^2.20.12",
|
||||
"@clerk/types": "^4.42.0",
|
||||
"crypto-js": "4.2.0",
|
||||
"server-only": "0.0.1",
|
||||
"tslib": "2.4.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.17.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"next": "^13.5.4 || ^14.0.3 || ^15.0.0",
|
||||
"react": "^18.0.0 || ^19.0.0 || ^19.0.0-0",
|
||||
"react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@clerk/nextjs/node_modules/tslib": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz",
|
||||
"integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/@clerk/shared": {
|
||||
"version": "2.20.12",
|
||||
"resolved": "https://registry.npmjs.org/@clerk/shared/-/shared-2.20.12.tgz",
|
||||
"integrity": "sha512-uy9Z2h0VXbQ4xwjj8mKuQSwm8MEFTAec+3gu4MSTyc1WboaPfX3MnO3qjqJEwu/oQkakocVI0P3nViYbXokZtQ==",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@clerk/types": "^4.42.0",
|
||||
"dequal": "2.0.3",
|
||||
"glob-to-regexp": "0.4.1",
|
||||
"js-cookie": "3.0.5",
|
||||
"std-env": "^3.7.0",
|
||||
"swr": "^2.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.17.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^18.0.0 || ^19.0.0 || ^19.0.0-0",
|
||||
"react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react": {
|
||||
"optional": true
|
||||
},
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@clerk/types": {
|
||||
"version": "4.42.0",
|
||||
"resolved": "https://registry.npmjs.org/@clerk/types/-/types-4.42.0.tgz",
|
||||
"integrity": "sha512-SPBRHdP+ZggeudncbSj8KLOZ5PdVmtgZhL+tXremVJrETi9WHpf1UOYgnIHl+clp6GZC2IQM4tq57RSrHf0Oew==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"csstype": "3.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.17.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@clerk/types/node_modules/csstype": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
|
||||
"integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@drizzle-team/brocli": {
|
||||
"version": "0.10.2",
|
||||
"resolved": "https://registry.npmjs.org/@drizzle-team/brocli/-/brocli-0.10.2.tgz",
|
||||
@@ -4022,6 +4155,12 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/crypto-js": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
|
||||
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/css-vendor": {
|
||||
"version": "2.0.8",
|
||||
"resolved": "https://registry.npmjs.org/css-vendor/-/css-vendor-2.0.8.tgz",
|
||||
@@ -4183,6 +4322,15 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/dequal": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
|
||||
"integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/detect-libc": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz",
|
||||
@@ -4223,6 +4371,16 @@
|
||||
"csstype": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/dot-case": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz",
|
||||
"integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"no-case": "^3.0.4",
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.4.7",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz",
|
||||
@@ -5836,6 +5994,12 @@
|
||||
"node": ">=10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/glob-to-regexp": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz",
|
||||
"integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==",
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/globals": {
|
||||
"version": "13.24.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz",
|
||||
@@ -6491,6 +6655,15 @@
|
||||
"url": "https://github.com/sponsors/panva"
|
||||
}
|
||||
},
|
||||
"node_modules/js-cookie": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz",
|
||||
"integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
@@ -6740,6 +6913,15 @@
|
||||
"loose-envify": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/lower-case": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz",
|
||||
"integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "10.4.3",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
|
||||
@@ -6754,6 +6936,18 @@
|
||||
"react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc"
|
||||
}
|
||||
},
|
||||
"node_modules/map-obj": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/map-obj/-/map-obj-4.3.0.tgz",
|
||||
"integrity": "sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/merge2": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
|
||||
@@ -6976,6 +7170,16 @@
|
||||
"node": "^10 || ^12 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/no-case": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz",
|
||||
"integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"lower-case": "^2.0.2",
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/node-releases": {
|
||||
"version": "2.0.18",
|
||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz",
|
||||
@@ -7958,6 +8162,12 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/server-only": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/server-only/-/server-only-0.0.1.tgz",
|
||||
"integrity": "sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/set-function-length": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
|
||||
@@ -8086,6 +8296,42 @@
|
||||
"is-arrayish": "^0.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/snake-case": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz",
|
||||
"integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dot-case": "^3.0.4",
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/snakecase-keys": {
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/snakecase-keys/-/snakecase-keys-8.0.1.tgz",
|
||||
"integrity": "sha512-Sj51kE1zC7zh6TDlNNz0/Jn1n5HiHdoQErxO8jLtnyrkJW/M5PrI7x05uDgY3BO7OUQYKCvmeMurW6BPUdwEOw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"map-obj": "^4.1.0",
|
||||
"snake-case": "^3.0.4",
|
||||
"type-fest": "^4.15.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/snakecase-keys/node_modules/type-fest": {
|
||||
"version": "4.33.0",
|
||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.33.0.tgz",
|
||||
"integrity": "sha512-s6zVrxuyKbbAsSAD5ZPTB77q4YIdRctkTbJ2/Dqlinwz+8ooH2gd+YA7VA6Pa93KML9GockVvoxjZ2vHP+mu8g==",
|
||||
"license": "(MIT OR CC0-1.0)",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.5.7",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
|
||||
@@ -8129,6 +8375,12 @@
|
||||
"node": ">= 10.x"
|
||||
}
|
||||
},
|
||||
"node_modules/std-env": {
|
||||
"version": "3.8.0",
|
||||
"resolved": "https://registry.npmjs.org/std-env/-/std-env-3.8.0.tgz",
|
||||
"integrity": "sha512-Bc3YwwCB+OzldMxOXJIIvC6cPRWr/LxOp48CdQTOkPyk/t4JWWJbrilwBd7RJzKV8QW7tJkcgAmeuLLJugl5/w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/streamsearch": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
|
||||
@@ -8452,6 +8704,19 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/swr": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/swr/-/swr-2.3.0.tgz",
|
||||
"integrity": "sha512-NyZ76wA4yElZWBHzSgEJc28a0u6QZvhb6w0azeL2k7+Q1gAzVK+IqQYXhVOC/mzi+HZIozrZvBVeSeOZNR2bqA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dequal": "^2.0.3",
|
||||
"use-sync-external-store": "^1.4.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tabbable": {
|
||||
"version": "6.2.0",
|
||||
"resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.2.0.tgz",
|
||||
@@ -8813,6 +9078,15 @@
|
||||
"punycode": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/use-sync-external-store": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.4.0.tgz",
|
||||
"integrity": "sha512-9WXSPC5fMv61vaupRkCKCxsPxBocVnwakBEkMIHHpkTTg6icbJtg6jzgtLDm4bl3cSHAca52rYWih0k4K3PfHw==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/util": {
|
||||
"version": "0.10.4",
|
||||
"resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@clerk/nextjs": "^6.10.0",
|
||||
"@emotion/react": "^11.13.5",
|
||||
"@emotion/styled": "^11.13.5",
|
||||
"@headlessui/react": "^2.2.0",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use server';
|
||||
import { eq, not , asc} from "drizzle-orm";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { db } from "@db/index";
|
||||
import { db } from "@src/db";
|
||||
import { users } from "@schemas/schema";
|
||||
|
||||
export const getData = async () => {
|
||||
@@ -14,7 +14,7 @@ export const getAllUsersOrdrByLastname = async () => {
|
||||
};
|
||||
|
||||
export const getUserByEmail = async (email:string) => {
|
||||
return getData();
|
||||
return await db.select().from(users).where(eq(users.email, email));
|
||||
};
|
||||
|
||||
export const getUserByUUID = async (uuid:string) => {
|
||||
@@ -22,10 +22,23 @@ export const getUserByUUID = async (uuid:string) => {
|
||||
return data[0];
|
||||
};
|
||||
|
||||
export const addUser = async ( first_name: string, last_name: string, username: string, email: string, password_hash : string) => {
|
||||
/*export const addUser = async ( first_name: string, last_name: string, username: string, email: string, password_hash : string) => {
|
||||
await db.insert(users).values({
|
||||
first_name : first_name, last_name: last_name, username: email, email: email, password_hash : password_hash
|
||||
});
|
||||
};*/
|
||||
export const addUser = async (first_name: string, last_name: string, username: string, email: string, password_hash: string) => {
|
||||
const [addedUser] = await db.insert(users).values({
|
||||
name: `${first_name} ${last_name}`,
|
||||
first_name: first_name,
|
||||
last_name: last_name,
|
||||
username: email,
|
||||
email: email,
|
||||
password_hash: password_hash,
|
||||
full_name: `${first_name} ${last_name}`,
|
||||
}).returning(); // Returns the inserted user (adjust "*" to specific columns if necessary)
|
||||
|
||||
return addedUser;
|
||||
};
|
||||
|
||||
export const deleteUser = async (id: string) => {
|
||||
|
||||
@@ -4,7 +4,14 @@ import PopNav from "@components/PopNav/page";
|
||||
import { Roboto } from 'next/font/google'
|
||||
import constants from "@src/lib/constants";
|
||||
import Footer from "@components/footer";
|
||||
|
||||
import '../styles/globals.css'
|
||||
import {
|
||||
ClerkProvider,
|
||||
SignInButton,
|
||||
SignedIn,
|
||||
SignedOut,
|
||||
UserButton
|
||||
} from '@clerk/nextjs';
|
||||
export const metadata = {
|
||||
title: constants.APP_NAME,
|
||||
description: constants.DESCRIPTION,
|
||||
@@ -21,14 +28,25 @@ export default function RootLayout(props: { children: React.ReactNode }) {
|
||||
const { children } = props;
|
||||
|
||||
return (
|
||||
<html suppressHydrationWarning className={roboto.className}>
|
||||
<ClerkProvider>
|
||||
<html lang="en" suppressHydrationWarning className={roboto.className}>
|
||||
<body className="bg-slate-200 ">
|
||||
|
||||
<header>
|
||||
<SignedOut>
|
||||
<SignInButton />
|
||||
</SignedOut>
|
||||
<SignedIn>
|
||||
<UserButton />
|
||||
</SignedIn>
|
||||
</header>
|
||||
<Navbar />
|
||||
<PopNav />
|
||||
<main>
|
||||
{children}
|
||||
</main>
|
||||
<Footer />
|
||||
</body>
|
||||
</html>
|
||||
</ClerkProvider>
|
||||
)
|
||||
}
|
||||
@@ -27,15 +27,17 @@ export default function RegistrationForm() {
|
||||
return;
|
||||
}
|
||||
|
||||
const existingUser : any = null;
|
||||
if((await getUserByEmail(formData.email)).length > 0){
|
||||
let existingUser : any = null;
|
||||
existingUser = await getUserByEmail(formData.email);
|
||||
console.log(existingUser);
|
||||
if(existingUser.length > 0){
|
||||
setError("Duplicate E-Mail Address");
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const hashedPassword = await bcrypt.hash(formData.password, 10);
|
||||
addUser(
|
||||
await addUser(
|
||||
formData.first_name,
|
||||
formData.last_name,
|
||||
formData.username,
|
||||
|
||||
@@ -16,9 +16,8 @@ export const products = pgTable("products", {
|
||||
|
||||
|
||||
export const users = pgTable("users", {
|
||||
id: text("id")
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
name: varchar("name").notNull(),
|
||||
username: varchar({ length: 50 }).notNull(),
|
||||
email: varchar({ length: 255 }).notNull(),
|
||||
emailVerifiedOn: timestamp("email_verified_on", { mode: "date" }),
|
||||
@@ -27,6 +26,7 @@ export const users = pgTable("users", {
|
||||
last_name: varchar("last_name", { length: 50 }),
|
||||
full_name: varchar("full_name", { length: 50 }),
|
||||
profilePicture: varchar("profile_picture", { length: 255 }),
|
||||
image: text("image"),
|
||||
dateOfBirth: date("date_of_birth"),
|
||||
phoneNumber: varchar("phone_number", { length: 20 }),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).default(sql`CURRENT_TIMESTAMP`),
|
||||
@@ -92,9 +92,10 @@ export const brands = pgTable("brands", {
|
||||
});
|
||||
|
||||
export const sessions = pgTable("sessions", {
|
||||
sessionToken: text().primaryKey().notNull(),
|
||||
userId: text().notNull(),
|
||||
expires: timestamp({ mode: 'string' }).notNull(),
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
sessionToken: varchar("session_token").notNull(),
|
||||
userId: uuid("user_id").notNull(),
|
||||
expires: timestamp("expires").notNull(),
|
||||
});
|
||||
|
||||
export const manufacturer = pgTable("manufacturer", {
|
||||
@@ -399,13 +400,9 @@ export const balResellers = pgTable("bal_resellers", {
|
||||
});
|
||||
|
||||
export const verificationTokens = pgTable("verificationTokens", {
|
||||
identifier: text().notNull(),
|
||||
token: text().notNull(),
|
||||
expires: timestamp({ mode: 'string' }).notNull(),
|
||||
}, (table) => {
|
||||
return {
|
||||
verificationTokenIdentifierTokenPk: primaryKey({ columns: [table.identifier, table.token], name: "verificationToken_identifier_token_pk"}),
|
||||
}
|
||||
identifier: varchar("identifier").notNull(),
|
||||
token: varchar("token").notNull(),
|
||||
expires: timestamp("expires").notNull(),
|
||||
});
|
||||
|
||||
export const authenticator = pgTable("authenticator", {
|
||||
@@ -425,25 +422,23 @@ export const authenticator = pgTable("authenticator", {
|
||||
});
|
||||
|
||||
export const accounts = pgTable("accounts", {
|
||||
uuid: uuid().defaultRandom(),
|
||||
userId: text("user_id").notNull(),
|
||||
type: text().notNull(),
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
uuid: uuid("uuid").defaultRandom(),
|
||||
userId: uuid("user_id").notNull(),
|
||||
type: varchar("type").notNull(),
|
||||
provider: text().notNull(),
|
||||
providerAccountId: text("provider_account_id").notNull(),
|
||||
providerAccountId: varchar("provider_account_id").notNull(),
|
||||
refreshToken: text("refresh_token"),
|
||||
accessToken: text("access_token"),
|
||||
expiresAt: integer("expires_at"),
|
||||
tokenType: text("token_type"),
|
||||
scope: text(),
|
||||
tokenType: varchar("token_type"),
|
||||
idToken: text("id_token"),
|
||||
sessionState: text("session_state"),
|
||||
}, (table) => {
|
||||
return {
|
||||
accountProviderProviderAccountIdPk: primaryKey({ columns: [table.provider, table.providerAccountId], name: "account_provider_providerAccountId_pk"}),
|
||||
sessionState: varchar("session_state"),
|
||||
scope: text(),
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
export const vw_accounts = pgView("vw_accounts", {
|
||||
/* export const vw_accounts = pgView("vw_accounts", {
|
||||
uuid: uuid().defaultRandom(),
|
||||
userId: text("user_id").notNull(),
|
||||
type: text().notNull(),
|
||||
@@ -459,4 +454,4 @@ export const vw_accounts = pgView("vw_accounts", {
|
||||
first_name: text("first_name"),
|
||||
last_name: text("last_name"),
|
||||
|
||||
},).existing();
|
||||
},).existing(); */
|
||||
12
src/middleware.ts
Normal file
12
src/middleware.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { clerkMiddleware } from "@clerk/nextjs/server";
|
||||
|
||||
export default clerkMiddleware();
|
||||
|
||||
export const config = {
|
||||
matcher: [
|
||||
// Skip Next.js internals and all static files, unless found in search params
|
||||
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
|
||||
// Always run for API routes
|
||||
'/(api|trpc)(.*)',
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user