Cleanup. Stuff from yesterday idk
This commit is contained in:
@ -24,7 +24,7 @@
|
||||
"@radix-ui/react-separator": "^1.1.7",
|
||||
"@radix-ui/react-slot": "^1.2.3",
|
||||
"@supabase/ssr": "^0.6.1",
|
||||
"@supabase/supabase-js": "^2.49.10",
|
||||
"@supabase/supabase-js": "^2.50.0",
|
||||
"@t3-oss/env-nextjs": "^0.12.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
@ -35,14 +35,14 @@
|
||||
"react-dom": "^19.1.0",
|
||||
"react-hook-form": "^7.57.0",
|
||||
"sonner": "^2.0.5",
|
||||
"zod": "^3.25.51"
|
||||
"zod": "^3.25.55"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.3.1",
|
||||
"@tailwindcss/postcss": "^4.1.8",
|
||||
"@types/cors": "^2.8.18",
|
||||
"@types/express": "^5.0.2",
|
||||
"@types/node": "^20.17.57",
|
||||
"@types/node": "^20.19.0",
|
||||
"@types/react": "^19.1.6",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"eslint": "^9.28.0",
|
||||
|
230
pnpm-lock.yaml
generated
230
pnpm-lock.yaml
generated
@ -31,13 +31,13 @@ importers:
|
||||
version: 1.2.3(@types/react@19.1.6)(react@19.1.0)
|
||||
'@supabase/ssr':
|
||||
specifier: ^0.6.1
|
||||
version: 0.6.1(@supabase/supabase-js@2.49.10)
|
||||
version: 0.6.1(@supabase/supabase-js@2.50.0)
|
||||
'@supabase/supabase-js':
|
||||
specifier: ^2.49.10
|
||||
version: 2.49.10
|
||||
specifier: ^2.50.0
|
||||
version: 2.50.0
|
||||
'@t3-oss/env-nextjs':
|
||||
specifier: ^0.12.0
|
||||
version: 0.12.0(typescript@5.8.3)(zod@3.25.51)
|
||||
version: 0.12.0(typescript@5.8.3)(zod@3.25.55)
|
||||
class-variance-authority:
|
||||
specifier: ^0.7.1
|
||||
version: 0.7.1
|
||||
@ -66,8 +66,8 @@ importers:
|
||||
specifier: ^2.0.5
|
||||
version: 2.0.5(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
zod:
|
||||
specifier: ^3.25.51
|
||||
version: 3.25.51
|
||||
specifier: ^3.25.55
|
||||
version: 3.25.55
|
||||
devDependencies:
|
||||
'@eslint/eslintrc':
|
||||
specifier: ^3.3.1
|
||||
@ -82,8 +82,8 @@ importers:
|
||||
specifier: ^5.0.2
|
||||
version: 5.0.2
|
||||
'@types/node':
|
||||
specifier: ^20.17.57
|
||||
version: 20.17.57
|
||||
specifier: ^20.19.0
|
||||
version: 20.19.0
|
||||
'@types/react':
|
||||
specifier: ^19.1.6
|
||||
version: 19.1.6
|
||||
@ -777,8 +777,8 @@ packages:
|
||||
'@standard-schema/utils@0.3.0':
|
||||
resolution: {integrity: sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==}
|
||||
|
||||
'@supabase/auth-js@2.69.1':
|
||||
resolution: {integrity: sha512-FILtt5WjCNzmReeRLq5wRs3iShwmnWgBvxHfqapC/VoljJl+W8hDAyFmf1NVw3zH+ZjZ05AKxiKxVeb0HNWRMQ==}
|
||||
'@supabase/auth-js@2.70.0':
|
||||
resolution: {integrity: sha512-BaAK/tOAZFJtzF1sE3gJ2FwTjLf4ky3PSvcvLGEgEmO4BSBkwWKu8l67rLLIBZPDnCyV7Owk2uPyKHa0kj5QGg==}
|
||||
|
||||
'@supabase/functions-js@2.4.4':
|
||||
resolution: {integrity: sha512-WL2p6r4AXNGwop7iwvul2BvOtuJ1YQy8EbOd0dhG1oN1q8el/BIRSFCFnWAMM/vJJlHWLi4ad22sKbKr9mvjoA==}
|
||||
@ -801,8 +801,8 @@ packages:
|
||||
'@supabase/storage-js@2.7.1':
|
||||
resolution: {integrity: sha512-asYHcyDR1fKqrMpytAS1zjyEfvxuOIp1CIXX7ji4lHHcJKqyk+sLl/Vxgm4sN6u8zvuUtae9e4kDxQP2qrwWBA==}
|
||||
|
||||
'@supabase/supabase-js@2.49.10':
|
||||
resolution: {integrity: sha512-IRPcIdncuhD2m1eZ2Fkg0S1fq9SXlHfmAetBxPN66kVFtTucR8b01xKuVmKqcIJokB17umMf1bmqyS8yboXGsw==}
|
||||
'@supabase/supabase-js@2.50.0':
|
||||
resolution: {integrity: sha512-M1Gd5tPaaghYZ9OjeO1iORRqbTWFEz/cF3pPubRnMPzA+A8SiUsXXWDP+DWsASZcjEcVEcVQIAF38i5wrijYOg==}
|
||||
|
||||
'@swc/counter@0.1.3':
|
||||
resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==}
|
||||
@ -938,8 +938,8 @@ packages:
|
||||
'@types/cors@2.8.18':
|
||||
resolution: {integrity: sha512-nX3d0sxJW41CqQvfOzVG1NCTXfFDrDWIghCZncpHeWlVFd81zxB/DLhg7avFg6eHLCRX7ckBmoIIcqa++upvJA==}
|
||||
|
||||
'@types/estree@1.0.7':
|
||||
resolution: {integrity: sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==}
|
||||
'@types/estree@1.0.8':
|
||||
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
|
||||
|
||||
'@types/express-serve-static-core@5.0.6':
|
||||
resolution: {integrity: sha512-3xhRnjJPkULekpSzgtoNYYcTWgEZkp4myc+Saevii5JPnHNvHMRlBSHDbs7Bh1iPPoVTERHEZXyhyLbMEsExsA==}
|
||||
@ -959,8 +959,8 @@ packages:
|
||||
'@types/mime@1.3.5':
|
||||
resolution: {integrity: sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==}
|
||||
|
||||
'@types/node@20.17.57':
|
||||
resolution: {integrity: sha512-f3T4y6VU4fVQDKVqJV4Uppy8c1p/sVvS3peyqxyWnzkqXFJLRU7Y1Bl7rMS1Qe9z0v4M6McY0Fp9yBsgHJUsWQ==}
|
||||
'@types/node@20.19.0':
|
||||
resolution: {integrity: sha512-hfrc+1tud1xcdVTABC2JiomZJEklMcXYNTVtZLAeqTVWD+qL5jkHKT+1lOtqDdGxt+mB53DTtiz673vfjU8D1Q==}
|
||||
|
||||
'@types/phoenix@1.6.6':
|
||||
resolution: {integrity: sha512-PIzZZlEppgrpoT2QgbnDU+MMzuR6BbCjllj0bM70lWoejMeNJAxCchxnv7J3XFkI8MpygtRpzXrIlmWUBclP5A==}
|
||||
@ -1047,88 +1047,88 @@ packages:
|
||||
resolution: {integrity: sha512-3i8NrFcZeeDHJ+7ZUuDkGT+UHq+XoFGsymNK2jZCOHcfEzRQ0BdpRtdpSx/Iyf3MHLWIcLS0COuOPibKQboIiQ==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
|
||||
'@unrs/resolver-binding-darwin-arm64@1.7.9':
|
||||
resolution: {integrity: sha512-hWbcVTcNqgUirY5DC3heOLrz35D926r2izfxveBmuIgDwx9KkUHfqd93g8PtROJX01lvhmyAc3E09/ma6jhyqQ==}
|
||||
'@unrs/resolver-binding-darwin-arm64@1.7.11':
|
||||
resolution: {integrity: sha512-i3/wlWjQJXMh1uiGtiv7k1EYvrrS3L1hdwmWJJiz1D8jWy726YFYPIxQWbEIVPVAgrfRR0XNlLrTQwq17cuCGw==}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@unrs/resolver-binding-darwin-x64@1.7.9':
|
||||
resolution: {integrity: sha512-NCZb/oaXELjt8jtm6ztlNPpAxKZsKIxsGYPSxkwQdQ/zl7X2PfyCpWqwoGE4A9vCP6gAgJnvH3e22nE0qk9ieA==}
|
||||
'@unrs/resolver-binding-darwin-x64@1.7.11':
|
||||
resolution: {integrity: sha512-8XXyFvc6w6kmMmi6VYchZhjd5CDcp+Lv6Cn1YmUme0ypsZ/0Kzd+9ESrWtDrWibKPTgSteDTxp75cvBOY64FQQ==}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@unrs/resolver-binding-freebsd-x64@1.7.9':
|
||||
resolution: {integrity: sha512-/AYheGgFn9Pw3X3pYFCohznydaUA9980/wlwgbgCsVxnY4IbqVoZhTLQZ4JWKKaOWBwwmM8FseHf5h5OawyOQQ==}
|
||||
'@unrs/resolver-binding-freebsd-x64@1.7.11':
|
||||
resolution: {integrity: sha512-0qJBYzP8Qk24CZ05RSWDQUjdiQUeIJGfqMMzbtXgCKl/a5xa6thfC0MQkGIr55LCLd6YmMyO640ifYUa53lybQ==}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@unrs/resolver-binding-linux-arm-gnueabihf@1.7.9':
|
||||
resolution: {integrity: sha512-RYV9sEH3o6SZum5wGb9evXlgibsVfluuiyi09hXVD+qPRrCSB45h3z1HjZpe9+c25GiN53CEy149fYS0fLVBtw==}
|
||||
'@unrs/resolver-binding-linux-arm-gnueabihf@1.7.11':
|
||||
resolution: {integrity: sha512-1sGwpgvx+WZf0GFT6vkkOm6UJ+mlsVnjw+Yv9esK71idWeRAG3bbpkf3AoY8KIqKqmnzJExi0uKxXpakQ5Pcbg==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@unrs/resolver-binding-linux-arm-musleabihf@1.7.9':
|
||||
resolution: {integrity: sha512-0ishMZMCYNJd4SNjHnjByHWh6ia7EDVZrOVAW8wf9Vz2PTZ0pLrFwu5c9voHouGKg7s2cnzPz87c0OK7dwimUQ==}
|
||||
'@unrs/resolver-binding-linux-arm-musleabihf@1.7.11':
|
||||
resolution: {integrity: sha512-D/1F/2lTe+XAl3ohkYj51NjniVly8sIqkA/n1aOND3ZMO418nl2JNU95iVa1/RtpzaKcWEsNTtHRogykrUflJg==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@unrs/resolver-binding-linux-arm64-gnu@1.7.9':
|
||||
resolution: {integrity: sha512-FOspRldYylONzWCkF5n/B1MMYKXXlg2bzgcgESEVcP4LFh0eom/0XsWvfy+dlfBJ+FkYfJjvBJeje14xOBOa6g==}
|
||||
'@unrs/resolver-binding-linux-arm64-gnu@1.7.11':
|
||||
resolution: {integrity: sha512-7vFWHLCCNFLEQlmwKQfVy066ohLLArZl+AV/AdmrD1/pD1FlmqM+FKbtnONnIwbHtgetFUCV/SRi1q4D49aTlw==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@unrs/resolver-binding-linux-arm64-musl@1.7.9':
|
||||
resolution: {integrity: sha512-P1S5jTht888/1mZVrBZx8IOxpikRDPoECxod1CcAHYUZGUNr+PNp1m5eB9FWMK2zRCJ8HgHNZfdRyDf9pNCrlQ==}
|
||||
'@unrs/resolver-binding-linux-arm64-musl@1.7.11':
|
||||
resolution: {integrity: sha512-tYkGIx8hjWPh4zcn17jLEHU8YMmdP2obRTGkdaB3BguGHh31VCS3ywqC4QjTODjmhhNyZYkj/1Dz/+0kKvg9YA==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@unrs/resolver-binding-linux-ppc64-gnu@1.7.9':
|
||||
resolution: {integrity: sha512-cD9+BPxlFSiIkGWknSgKdTMGZIzCtSIg/O7GJ1LoC+jGtUOBNBJYMn6FyEPRvdpphewYzaCuPsikrMkpdX303Q==}
|
||||
'@unrs/resolver-binding-linux-ppc64-gnu@1.7.11':
|
||||
resolution: {integrity: sha512-6F328QIUev29vcZeRX6v6oqKxfUoGwIIAhWGD8wSysnBYFY0nivp25jdWmAb1GildbCCaQvOKEhCok7YfWkj4Q==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
|
||||
'@unrs/resolver-binding-linux-riscv64-gnu@1.7.9':
|
||||
resolution: {integrity: sha512-Z6IuWg9u0257dCVgc/x/zIKamqJhrmaOFuq3AYsSt6ZtyEHoyD5kxdXQUvEgBAd/Fn1b8tsX+VD9mB9al5306Q==}
|
||||
'@unrs/resolver-binding-linux-riscv64-gnu@1.7.11':
|
||||
resolution: {integrity: sha512-NqhWmiGJGdzbZbeucPZIG9Iav4lyYLCarEnxAceguMx9qlpeEF7ENqYKOwB8Zqk7/CeuYMEcLYMaW2li6HyDzQ==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
|
||||
'@unrs/resolver-binding-linux-riscv64-musl@1.7.9':
|
||||
resolution: {integrity: sha512-HpINrXLJVEpvkHHIla6pqhMAKbQBrY+2946i6rF6OlByONLTuObg65bcv3A38qV9yqJ7vtE0FyfNn68k0uQKbg==}
|
||||
'@unrs/resolver-binding-linux-riscv64-musl@1.7.11':
|
||||
resolution: {integrity: sha512-J2RPIFKMdTrLtBdfR1cUMKl8Gcy05nlQ+bEs/6al7EdWLk9cs3tnDREHZ7mV9uGbeghpjo4i8neNZNx3PYUY9w==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
|
||||
'@unrs/resolver-binding-linux-s390x-gnu@1.7.9':
|
||||
resolution: {integrity: sha512-ZXZFfaPFXnrDIPpkFoAZmxzXwqqfCHfnFdZhrEd+mrc/hHTQyxINyzrFMFCqtAa5eIjD7vgzNIXsMFU2QBnCPw==}
|
||||
'@unrs/resolver-binding-linux-s390x-gnu@1.7.11':
|
||||
resolution: {integrity: sha512-bDpGRerHvvHdhun7MmFUNDpMiYcJSqWckwAVVRTJf8F+RyqYJOp/mx04PDc7DhpNPeWdnTMu91oZRMV+gGaVcQ==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
|
||||
'@unrs/resolver-binding-linux-x64-gnu@1.7.9':
|
||||
resolution: {integrity: sha512-EzeeaZnuQOa93ox08oa9DqgQc8sK59jfs+apOUrZZSJCDG1ZbtJINPc8uRqE7p3Z66FPAe/uO3+7jZTkWbVDfg==}
|
||||
'@unrs/resolver-binding-linux-x64-gnu@1.7.11':
|
||||
resolution: {integrity: sha512-G9U7bVmylzRLma3cK39RBm3guoD1HOvY4o0NS4JNm37AD0lS7/xyMt7kn0JejYyc0Im8J+rH69/dXGM9DAJcSQ==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@unrs/resolver-binding-linux-x64-musl@1.7.9':
|
||||
resolution: {integrity: sha512-a07ezNt0OY8Vv/iDreJo7ZkKtwRb6UCYaCcMY2nm3ext7rTtDFS7X1GePqrbByvIbRFd6E5q1CKBPzJk6M360Q==}
|
||||
'@unrs/resolver-binding-linux-x64-musl@1.7.11':
|
||||
resolution: {integrity: sha512-7qL20SBKomekSunm7M9Fe5L93bFbn+FbHiGJbfTlp0RKhPVoJDP73vOxf1QrmJHyDPECsGWPFnKa/f8fO2FsHw==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@unrs/resolver-binding-wasm32-wasi@1.7.9':
|
||||
resolution: {integrity: sha512-d0fHnxgtrv75Po6LKJLjo1LFC5S0E8vv86H/5wGDFLG0AvS/0k+SghgUW6zAzjM2XRAic/qcy9+O7n/5JOjxFA==}
|
||||
'@unrs/resolver-binding-wasm32-wasi@1.7.11':
|
||||
resolution: {integrity: sha512-jisvIva8MidjI+B1lFRZZMfCPaCISePgTyR60wNT1MeQvIh5Ksa0G3gvI+Iqyj3jqYbvOHByenpa5eDGcSdoSg==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
cpu: [wasm32]
|
||||
|
||||
'@unrs/resolver-binding-win32-arm64-msvc@1.7.9':
|
||||
resolution: {integrity: sha512-0MFcaQDsUYxNqRxjPdsMKg1OGtmsqLzPY2Nwiiyalx6HFvkcHxgRCAOppgeUuDucpUEf76k/4tBzfzPxjYkFUg==}
|
||||
'@unrs/resolver-binding-win32-arm64-msvc@1.7.11':
|
||||
resolution: {integrity: sha512-G+H5nQZ8sRZ8ebMY6mRGBBvTEzMYEcgVauLsNHpvTUavZoCCRVP1zWkCZgOju2dW3O22+8seTHniTdl1/uLz3g==}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@unrs/resolver-binding-win32-ia32-msvc@1.7.9':
|
||||
resolution: {integrity: sha512-SiewmebiN32RpzrV1Dvbw7kdDCRuPThdgEWKJvDNcEGnVEV3ScYGuk5smJjKHXszqNX3mIXG/PcCXqHsE/7XGA==}
|
||||
'@unrs/resolver-binding-win32-ia32-msvc@1.7.11':
|
||||
resolution: {integrity: sha512-Hfy46DBfFzyv0wgR0MMOwFFib2W2+Btc8oE5h4XlPhpelnSyA6nFxkVIyTgIXYGTdFaLoZFNn62fmqx3rjEg3A==}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
|
||||
'@unrs/resolver-binding-win32-x64-msvc@1.7.9':
|
||||
resolution: {integrity: sha512-hORofIRZCm85+TUZ9OmHQJNlgtOmK/TPfvYeSplKAl+zQvAwMGyy6DZcSbrF+KdB1EDoGISwU7dX7PE92haOXg==}
|
||||
'@unrs/resolver-binding-win32-x64-msvc@1.7.11':
|
||||
resolution: {integrity: sha512-7L8NdsQlCJ8T106Gbz/AjzM4QKWVsoQbKpB9bMBGcIZswUuAnJMHpvbqGW3RBqLHCIwX4XZ5fxSBHEFcK2h9wA==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
@ -2442,11 +2442,11 @@ packages:
|
||||
resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
undici-types@6.19.8:
|
||||
resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==}
|
||||
undici-types@6.21.0:
|
||||
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
|
||||
|
||||
unrs-resolver@1.7.9:
|
||||
resolution: {integrity: sha512-hhFtY782YKwpz54G1db49YYS1RuMn8mBylIrCldrjb9BxZKnQ2xHw7+2zcl7H6fnUlTHGWv23/+677cpufhfxQ==}
|
||||
unrs-resolver@1.7.11:
|
||||
resolution: {integrity: sha512-OhuAzBImFPjKNgZ2JwHMfGFUA6NSbRegd1+BPjC1Y0E6X9Y/vJ4zKeGmIMqmlYboj6cMNEwKI+xQisrg4J0HaQ==}
|
||||
|
||||
uri-js@4.4.1:
|
||||
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
|
||||
@ -2527,8 +2527,8 @@ packages:
|
||||
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
zod@3.25.51:
|
||||
resolution: {integrity: sha512-TQSnBldh+XSGL+opiSIq0575wvDPqu09AqWe1F7JhUMKY+M91/aGlK4MhpVNO7MgYfHcVCB1ffwAUTJzllKJqg==}
|
||||
zod@3.25.55:
|
||||
resolution: {integrity: sha512-219huNnkSLQnLsQ3uaRjXsxMrVm5C9W3OOpEVt2k5tvMKuA8nBSu38e0B//a+he9Iq2dvmk2VyYVlHqiHa4YBA==}
|
||||
|
||||
snapshots:
|
||||
|
||||
@ -3093,7 +3093,7 @@ snapshots:
|
||||
|
||||
'@standard-schema/utils@0.3.0': {}
|
||||
|
||||
'@supabase/auth-js@2.69.1':
|
||||
'@supabase/auth-js@2.70.0':
|
||||
dependencies:
|
||||
'@supabase/node-fetch': 2.6.15
|
||||
|
||||
@ -3119,18 +3119,18 @@ snapshots:
|
||||
- bufferutil
|
||||
- utf-8-validate
|
||||
|
||||
'@supabase/ssr@0.6.1(@supabase/supabase-js@2.49.10)':
|
||||
'@supabase/ssr@0.6.1(@supabase/supabase-js@2.50.0)':
|
||||
dependencies:
|
||||
'@supabase/supabase-js': 2.49.10
|
||||
'@supabase/supabase-js': 2.50.0
|
||||
cookie: 1.0.2
|
||||
|
||||
'@supabase/storage-js@2.7.1':
|
||||
dependencies:
|
||||
'@supabase/node-fetch': 2.6.15
|
||||
|
||||
'@supabase/supabase-js@2.49.10':
|
||||
'@supabase/supabase-js@2.50.0':
|
||||
dependencies:
|
||||
'@supabase/auth-js': 2.69.1
|
||||
'@supabase/auth-js': 2.70.0
|
||||
'@supabase/functions-js': 2.4.4
|
||||
'@supabase/node-fetch': 2.6.15
|
||||
'@supabase/postgrest-js': 1.19.4
|
||||
@ -3146,17 +3146,17 @@ snapshots:
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
|
||||
'@t3-oss/env-core@0.12.0(typescript@5.8.3)(zod@3.25.51)':
|
||||
'@t3-oss/env-core@0.12.0(typescript@5.8.3)(zod@3.25.55)':
|
||||
optionalDependencies:
|
||||
typescript: 5.8.3
|
||||
zod: 3.25.51
|
||||
zod: 3.25.55
|
||||
|
||||
'@t3-oss/env-nextjs@0.12.0(typescript@5.8.3)(zod@3.25.51)':
|
||||
'@t3-oss/env-nextjs@0.12.0(typescript@5.8.3)(zod@3.25.55)':
|
||||
dependencies:
|
||||
'@t3-oss/env-core': 0.12.0(typescript@5.8.3)(zod@3.25.51)
|
||||
'@t3-oss/env-core': 0.12.0(typescript@5.8.3)(zod@3.25.55)
|
||||
optionalDependencies:
|
||||
typescript: 5.8.3
|
||||
zod: 3.25.51
|
||||
zod: 3.25.55
|
||||
|
||||
'@tailwindcss/node@4.1.8':
|
||||
dependencies:
|
||||
@ -3238,21 +3238,21 @@ snapshots:
|
||||
'@types/body-parser@1.19.5':
|
||||
dependencies:
|
||||
'@types/connect': 3.4.38
|
||||
'@types/node': 20.17.57
|
||||
'@types/node': 20.19.0
|
||||
|
||||
'@types/connect@3.4.38':
|
||||
dependencies:
|
||||
'@types/node': 20.17.57
|
||||
'@types/node': 20.19.0
|
||||
|
||||
'@types/cors@2.8.18':
|
||||
dependencies:
|
||||
'@types/node': 20.17.57
|
||||
'@types/node': 20.19.0
|
||||
|
||||
'@types/estree@1.0.7': {}
|
||||
'@types/estree@1.0.8': {}
|
||||
|
||||
'@types/express-serve-static-core@5.0.6':
|
||||
dependencies:
|
||||
'@types/node': 20.17.57
|
||||
'@types/node': 20.19.0
|
||||
'@types/qs': 6.14.0
|
||||
'@types/range-parser': 1.2.7
|
||||
'@types/send': 0.17.4
|
||||
@ -3271,9 +3271,9 @@ snapshots:
|
||||
|
||||
'@types/mime@1.3.5': {}
|
||||
|
||||
'@types/node@20.17.57':
|
||||
'@types/node@20.19.0':
|
||||
dependencies:
|
||||
undici-types: 6.19.8
|
||||
undici-types: 6.21.0
|
||||
|
||||
'@types/phoenix@1.6.6': {}
|
||||
|
||||
@ -3292,17 +3292,17 @@ snapshots:
|
||||
'@types/send@0.17.4':
|
||||
dependencies:
|
||||
'@types/mime': 1.3.5
|
||||
'@types/node': 20.17.57
|
||||
'@types/node': 20.19.0
|
||||
|
||||
'@types/serve-static@1.15.7':
|
||||
dependencies:
|
||||
'@types/http-errors': 2.0.4
|
||||
'@types/node': 20.17.57
|
||||
'@types/node': 20.19.0
|
||||
'@types/send': 0.17.4
|
||||
|
||||
'@types/ws@8.18.1':
|
||||
dependencies:
|
||||
'@types/node': 20.17.57
|
||||
'@types/node': 20.19.0
|
||||
|
||||
'@typescript-eslint/eslint-plugin@8.33.1(@typescript-eslint/parser@8.33.1(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)':
|
||||
dependencies:
|
||||
@ -3396,57 +3396,57 @@ snapshots:
|
||||
'@typescript-eslint/types': 8.33.1
|
||||
eslint-visitor-keys: 4.2.0
|
||||
|
||||
'@unrs/resolver-binding-darwin-arm64@1.7.9':
|
||||
'@unrs/resolver-binding-darwin-arm64@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-darwin-x64@1.7.9':
|
||||
'@unrs/resolver-binding-darwin-x64@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-freebsd-x64@1.7.9':
|
||||
'@unrs/resolver-binding-freebsd-x64@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-linux-arm-gnueabihf@1.7.9':
|
||||
'@unrs/resolver-binding-linux-arm-gnueabihf@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-linux-arm-musleabihf@1.7.9':
|
||||
'@unrs/resolver-binding-linux-arm-musleabihf@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-linux-arm64-gnu@1.7.9':
|
||||
'@unrs/resolver-binding-linux-arm64-gnu@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-linux-arm64-musl@1.7.9':
|
||||
'@unrs/resolver-binding-linux-arm64-musl@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-linux-ppc64-gnu@1.7.9':
|
||||
'@unrs/resolver-binding-linux-ppc64-gnu@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-linux-riscv64-gnu@1.7.9':
|
||||
'@unrs/resolver-binding-linux-riscv64-gnu@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-linux-riscv64-musl@1.7.9':
|
||||
'@unrs/resolver-binding-linux-riscv64-musl@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-linux-s390x-gnu@1.7.9':
|
||||
'@unrs/resolver-binding-linux-s390x-gnu@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-linux-x64-gnu@1.7.9':
|
||||
'@unrs/resolver-binding-linux-x64-gnu@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-linux-x64-musl@1.7.9':
|
||||
'@unrs/resolver-binding-linux-x64-musl@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-wasm32-wasi@1.7.9':
|
||||
'@unrs/resolver-binding-wasm32-wasi@1.7.11':
|
||||
dependencies:
|
||||
'@napi-rs/wasm-runtime': 0.2.10
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-win32-arm64-msvc@1.7.9':
|
||||
'@unrs/resolver-binding-win32-arm64-msvc@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-win32-ia32-msvc@1.7.9':
|
||||
'@unrs/resolver-binding-win32-ia32-msvc@1.7.11':
|
||||
optional: true
|
||||
|
||||
'@unrs/resolver-binding-win32-x64-msvc@1.7.9':
|
||||
'@unrs/resolver-binding-win32-x64-msvc@1.7.11':
|
||||
optional: true
|
||||
|
||||
acorn-jsx@5.3.2(acorn@8.14.1):
|
||||
@ -3841,7 +3841,7 @@ snapshots:
|
||||
is-bun-module: 2.0.0
|
||||
stable-hash: 0.0.5
|
||||
tinyglobby: 0.2.14
|
||||
unrs-resolver: 1.7.9
|
||||
unrs-resolver: 1.7.11
|
||||
optionalDependencies:
|
||||
eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.33.1(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.28.0(jiti@2.4.2))
|
||||
transitivePeerDependencies:
|
||||
@ -3954,7 +3954,7 @@ snapshots:
|
||||
'@humanfs/node': 0.16.6
|
||||
'@humanwhocodes/module-importer': 1.0.1
|
||||
'@humanwhocodes/retry': 0.4.3
|
||||
'@types/estree': 1.0.7
|
||||
'@types/estree': 1.0.8
|
||||
'@types/json-schema': 7.0.15
|
||||
ajv: 6.12.6
|
||||
chalk: 4.1.2
|
||||
@ -4945,29 +4945,29 @@ snapshots:
|
||||
has-symbols: 1.1.0
|
||||
which-boxed-primitive: 1.1.1
|
||||
|
||||
undici-types@6.19.8: {}
|
||||
undici-types@6.21.0: {}
|
||||
|
||||
unrs-resolver@1.7.9:
|
||||
unrs-resolver@1.7.11:
|
||||
dependencies:
|
||||
napi-postinstall: 0.2.4
|
||||
optionalDependencies:
|
||||
'@unrs/resolver-binding-darwin-arm64': 1.7.9
|
||||
'@unrs/resolver-binding-darwin-x64': 1.7.9
|
||||
'@unrs/resolver-binding-freebsd-x64': 1.7.9
|
||||
'@unrs/resolver-binding-linux-arm-gnueabihf': 1.7.9
|
||||
'@unrs/resolver-binding-linux-arm-musleabihf': 1.7.9
|
||||
'@unrs/resolver-binding-linux-arm64-gnu': 1.7.9
|
||||
'@unrs/resolver-binding-linux-arm64-musl': 1.7.9
|
||||
'@unrs/resolver-binding-linux-ppc64-gnu': 1.7.9
|
||||
'@unrs/resolver-binding-linux-riscv64-gnu': 1.7.9
|
||||
'@unrs/resolver-binding-linux-riscv64-musl': 1.7.9
|
||||
'@unrs/resolver-binding-linux-s390x-gnu': 1.7.9
|
||||
'@unrs/resolver-binding-linux-x64-gnu': 1.7.9
|
||||
'@unrs/resolver-binding-linux-x64-musl': 1.7.9
|
||||
'@unrs/resolver-binding-wasm32-wasi': 1.7.9
|
||||
'@unrs/resolver-binding-win32-arm64-msvc': 1.7.9
|
||||
'@unrs/resolver-binding-win32-ia32-msvc': 1.7.9
|
||||
'@unrs/resolver-binding-win32-x64-msvc': 1.7.9
|
||||
'@unrs/resolver-binding-darwin-arm64': 1.7.11
|
||||
'@unrs/resolver-binding-darwin-x64': 1.7.11
|
||||
'@unrs/resolver-binding-freebsd-x64': 1.7.11
|
||||
'@unrs/resolver-binding-linux-arm-gnueabihf': 1.7.11
|
||||
'@unrs/resolver-binding-linux-arm-musleabihf': 1.7.11
|
||||
'@unrs/resolver-binding-linux-arm64-gnu': 1.7.11
|
||||
'@unrs/resolver-binding-linux-arm64-musl': 1.7.11
|
||||
'@unrs/resolver-binding-linux-ppc64-gnu': 1.7.11
|
||||
'@unrs/resolver-binding-linux-riscv64-gnu': 1.7.11
|
||||
'@unrs/resolver-binding-linux-riscv64-musl': 1.7.11
|
||||
'@unrs/resolver-binding-linux-s390x-gnu': 1.7.11
|
||||
'@unrs/resolver-binding-linux-x64-gnu': 1.7.11
|
||||
'@unrs/resolver-binding-linux-x64-musl': 1.7.11
|
||||
'@unrs/resolver-binding-wasm32-wasi': 1.7.11
|
||||
'@unrs/resolver-binding-win32-arm64-msvc': 1.7.11
|
||||
'@unrs/resolver-binding-win32-ia32-msvc': 1.7.11
|
||||
'@unrs/resolver-binding-win32-x64-msvc': 1.7.11
|
||||
|
||||
uri-js@4.4.1:
|
||||
dependencies:
|
||||
@ -5052,4 +5052,4 @@ snapshots:
|
||||
|
||||
yocto-queue@0.1.0: {}
|
||||
|
||||
zod@3.25.51: {}
|
||||
zod@3.25.55: {}
|
||||
|
@ -36,10 +36,11 @@ export const GET = async (request: NextRequest) => {
|
||||
return redirect('/');
|
||||
if (type === 'recovery' || type === 'email_change')
|
||||
return redirect('/profile');
|
||||
if (type === 'invite')
|
||||
return redirect('/sign-up');
|
||||
if (type === 'invite') return redirect('/sign-up');
|
||||
}
|
||||
return redirect(`/?error=${encodeURIComponent(error?.message || 'Unknown error')}`);
|
||||
return redirect(
|
||||
`/?error=${encodeURIComponent(error?.message || 'Unknown error')}`,
|
||||
);
|
||||
}
|
||||
|
||||
return redirect('/');
|
||||
|
@ -27,7 +27,7 @@ const formSchema = z.object({
|
||||
email: z.string().email({
|
||||
message: 'Please enter a valid email address.',
|
||||
}),
|
||||
})
|
||||
});
|
||||
|
||||
const ForgotPassword = () => {
|
||||
const router = useRouter();
|
||||
@ -48,76 +48,82 @@ const ForgotPassword = () => {
|
||||
}
|
||||
}, [isAuthenticated, router]);
|
||||
|
||||
|
||||
const handleForgotPassword = async (values: z.infer<typeof formSchema>) => {
|
||||
try {
|
||||
setStatusMessage('');
|
||||
const formData = new FormData();
|
||||
const formData = new FormData();
|
||||
formData.append('email', values.email);
|
||||
const result = await forgotPassword(formData);
|
||||
if (result?.success) {
|
||||
await refreshUserData();
|
||||
setStatusMessage(result?.data ?? 'Check your email for a link to reset your password.')
|
||||
setStatusMessage(
|
||||
result?.data ?? 'Check your email for a link to reset your password.',
|
||||
);
|
||||
form.reset();
|
||||
router.push('');
|
||||
} else {
|
||||
setStatusMessage(`Error: ${result.error}`)
|
||||
setStatusMessage(`Error: ${result.error}`);
|
||||
}
|
||||
} catch (error) {
|
||||
setStatusMessage(
|
||||
`Error: ${error instanceof Error ? error.message : 'Could not sign in!'}`
|
||||
`Error: ${error instanceof Error ? error.message : 'Could not sign in!'}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className='min-w-xs md:min-w-sm'>
|
||||
<CardHeader>
|
||||
<CardTitle className='text-2xl font-medium'>Reset Password</CardTitle>
|
||||
<CardDescription className='text-sm text-foreground'>
|
||||
Don't have an account?{' '}
|
||||
<Link className='font-medium underline' href='/sign-up'>
|
||||
Sign up
|
||||
</Link>
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Form {...form} >
|
||||
<form
|
||||
onSubmit={form.handleSubmit(handleForgotPassword)}
|
||||
className='flex flex-col min-w-64 space-y-6'
|
||||
>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='email'
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Email</FormLabel>
|
||||
<FormControl>
|
||||
<Input type='email' placeholder='you@example.com' {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<SubmitButton
|
||||
disabled={isLoading}
|
||||
pendingText='Resetting Password...'
|
||||
>
|
||||
Reset Password
|
||||
</SubmitButton>
|
||||
{statusMessage && (
|
||||
statusMessage.includes('Error') ||
|
||||
statusMessage.includes('error') ||
|
||||
statusMessage.includes('failed') ||
|
||||
statusMessage.includes('invalid')
|
||||
? <StatusMessage message={{error: statusMessage}} />
|
||||
: <StatusMessage message={{ success: statusMessage }} />
|
||||
<Card className='min-w-xs md:min-w-sm'>
|
||||
<CardHeader>
|
||||
<CardTitle className='text-2xl font-medium'>Reset Password</CardTitle>
|
||||
<CardDescription className='text-sm text-foreground'>
|
||||
Don't have an account?{' '}
|
||||
<Link className='font-medium underline' href='/sign-up'>
|
||||
Sign up
|
||||
</Link>
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(handleForgotPassword)}
|
||||
className='flex flex-col min-w-64 space-y-6'
|
||||
>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='email'
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Email</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type='email'
|
||||
placeholder='you@example.com'
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
</form>
|
||||
</Form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
/>
|
||||
<SubmitButton
|
||||
disabled={isLoading}
|
||||
pendingText='Resetting Password...'
|
||||
>
|
||||
Reset Password
|
||||
</SubmitButton>
|
||||
{statusMessage &&
|
||||
(statusMessage.includes('Error') ||
|
||||
statusMessage.includes('error') ||
|
||||
statusMessage.includes('failed') ||
|
||||
statusMessage.includes('invalid') ? (
|
||||
<StatusMessage message={{ error: statusMessage }} />
|
||||
) : (
|
||||
<StatusMessage message={{ success: statusMessage }} />
|
||||
))}
|
||||
</form>
|
||||
</Form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
export default ForgotPassword;
|
||||
|
@ -2,7 +2,12 @@
|
||||
import { useAuth } from '@/components/context/auth';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useEffect } from 'react';
|
||||
import { AvatarUpload, ProfileForm, ResetPasswordForm, SignOut } from '@/components/default/profile';
|
||||
import {
|
||||
AvatarUpload,
|
||||
ProfileForm,
|
||||
ResetPasswordForm,
|
||||
SignOut,
|
||||
} from '@/components/default/profile';
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
@ -16,14 +21,20 @@ import { toast } from 'sonner';
|
||||
import { type Result } from '@/lib/actions';
|
||||
|
||||
const ProfilePage = () => {
|
||||
const { profile, isLoading, isAuthenticated, updateProfile, refreshUserData } = useAuth();
|
||||
const {
|
||||
profile,
|
||||
isLoading,
|
||||
isAuthenticated,
|
||||
updateProfile,
|
||||
refreshUserData,
|
||||
} = useAuth();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLoading && !isAuthenticated) {
|
||||
router.push('/sign-in');
|
||||
}
|
||||
}, [isLoading, isAuthenticated, router])
|
||||
}, [isLoading, isAuthenticated, router]);
|
||||
|
||||
const handleAvatarUploaded = async (path: string) => {
|
||||
await updateProfile({ avatar_url: path });
|
||||
@ -50,17 +61,17 @@ const ProfilePage = () => {
|
||||
try {
|
||||
const result = await resetPassword(formData);
|
||||
if (!result.success) {
|
||||
toast.error(`Error resetting password: ${result.error}`)
|
||||
return {success: false, error: result.error};
|
||||
toast.error(`Error resetting password: ${result.error}`);
|
||||
return { success: false, error: result.error };
|
||||
}
|
||||
return {success: true, data: null};
|
||||
return { success: true, data: null };
|
||||
} catch (error) {
|
||||
toast.error(
|
||||
`Error resetting password!: ${error as string ?? 'Unknown error'}`
|
||||
`Error resetting password!: ${(error as string) ?? 'Unknown error'}`,
|
||||
);
|
||||
return {success: false, error: 'Unknown error'};
|
||||
return { success: false, error: 'Unknown error' };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Show loading state while checking authentication
|
||||
if (isLoading) {
|
||||
@ -89,21 +100,21 @@ const ProfilePage = () => {
|
||||
Manage your personal information and how it appears to others
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
{isLoading && !profile ? (
|
||||
<div className='flex justify-center py-8'>
|
||||
<Loader2 className='h-8 w-8 animate-spin text-gray-500' />
|
||||
</div>
|
||||
) : (
|
||||
<div className='space-y-8'>
|
||||
<AvatarUpload onAvatarUploaded={handleAvatarUploaded} />
|
||||
<Separator />
|
||||
<ProfileForm onSubmit={handleProfileSubmit} />
|
||||
<Separator />
|
||||
<ResetPasswordForm onSubmit={handleResetPasswordSubmit} />
|
||||
<Separator />
|
||||
<SignOut />
|
||||
</div>
|
||||
)}
|
||||
{isLoading && !profile ? (
|
||||
<div className='flex justify-center py-8'>
|
||||
<Loader2 className='h-8 w-8 animate-spin text-gray-500' />
|
||||
</div>
|
||||
) : (
|
||||
<div className='space-y-8'>
|
||||
<AvatarUpload onAvatarUploaded={handleAvatarUploaded} />
|
||||
<Separator />
|
||||
<ProfileForm onSubmit={handleProfileSubmit} />
|
||||
<Separator />
|
||||
<ResetPasswordForm onSubmit={handleResetPasswordSubmit} />
|
||||
<Separator />
|
||||
<SignOut />
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
|
@ -34,7 +34,7 @@ const formSchema = z.object({
|
||||
password: z.string().min(8, {
|
||||
message: 'Password must be at least 8 characters.',
|
||||
}),
|
||||
})
|
||||
});
|
||||
|
||||
const Login = () => {
|
||||
const router = useRouter();
|
||||
@ -59,7 +59,7 @@ const Login = () => {
|
||||
const handleSignIn = async (values: z.infer<typeof formSchema>) => {
|
||||
try {
|
||||
setStatusMessage('');
|
||||
const formData = new FormData();
|
||||
const formData = new FormData();
|
||||
formData.append('email', values.email);
|
||||
formData.append('password', values.password);
|
||||
const result = await signIn(formData);
|
||||
@ -68,11 +68,11 @@ const Login = () => {
|
||||
form.reset();
|
||||
router.push('');
|
||||
} else {
|
||||
setStatusMessage(`Error: ${result.error}`)
|
||||
setStatusMessage(`Error: ${result.error}`);
|
||||
}
|
||||
} catch (error) {
|
||||
setStatusMessage(
|
||||
`Error: ${error instanceof Error ? error.message : 'Could not sign in!'}`
|
||||
`Error: ${error instanceof Error ? error.message : 'Could not sign in!'}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
@ -80,9 +80,7 @@ const Login = () => {
|
||||
return (
|
||||
<Card className='min-w-xs md:min-w-sm'>
|
||||
<CardHeader>
|
||||
<CardTitle className='text-3xl font-medium'>
|
||||
Sign In
|
||||
</CardTitle>
|
||||
<CardTitle className='text-3xl font-medium'>Sign In</CardTitle>
|
||||
<CardDescription className='text-foreground'>
|
||||
Don't have an account?{' '}
|
||||
<Link className='font-medium underline' href='/sign-up'>
|
||||
@ -103,7 +101,11 @@ const Login = () => {
|
||||
<FormItem>
|
||||
<FormLabel className='text-lg'>Email</FormLabel>
|
||||
<FormControl>
|
||||
<Input type='email' placeholder='you@example.com' {...field} />
|
||||
<Input
|
||||
type='email'
|
||||
placeholder='you@example.com'
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@ -125,20 +127,25 @@ const Login = () => {
|
||||
</Link>
|
||||
</div>
|
||||
<FormControl>
|
||||
<Input type='password' placeholder='Your password' {...field} />
|
||||
<Input
|
||||
type='password'
|
||||
placeholder='Your password'
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
{statusMessage && (
|
||||
statusMessage.includes('Error') ||
|
||||
statusMessage.includes('error') ||
|
||||
statusMessage.includes('failed') ||
|
||||
statusMessage.includes('invalid')
|
||||
? <StatusMessage message={{error: statusMessage}} />
|
||||
: <StatusMessage message={{ message: statusMessage }} />
|
||||
)}
|
||||
{statusMessage &&
|
||||
(statusMessage.includes('Error') ||
|
||||
statusMessage.includes('error') ||
|
||||
statusMessage.includes('failed') ||
|
||||
statusMessage.includes('invalid') ? (
|
||||
<StatusMessage message={{ error: statusMessage }} />
|
||||
) : (
|
||||
<StatusMessage message={{ message: statusMessage }} />
|
||||
))}
|
||||
<SubmitButton
|
||||
disabled={isLoading}
|
||||
pendingText='Signing In...'
|
||||
|
@ -45,7 +45,6 @@ const formSchema = z
|
||||
});
|
||||
|
||||
const SignUp = () => {
|
||||
|
||||
const router = useRouter();
|
||||
const { isAuthenticated, isLoading, refreshUserData } = useAuth();
|
||||
const [statusMessage, setStatusMessage] = useState('');
|
||||
@ -71,7 +70,7 @@ const SignUp = () => {
|
||||
const handleSignUp = async (values: z.infer<typeof formSchema>) => {
|
||||
try {
|
||||
setStatusMessage('');
|
||||
const formData = new FormData();
|
||||
const formData = new FormData();
|
||||
formData.append('name', values.name);
|
||||
formData.append('email', values.email);
|
||||
formData.append('password', values.password);
|
||||
@ -80,16 +79,16 @@ const SignUp = () => {
|
||||
await refreshUserData();
|
||||
setStatusMessage(
|
||||
result.data ??
|
||||
'Thanks for signing up! Please check your email for a verification link.'
|
||||
'Thanks for signing up! Please check your email for a verification link.',
|
||||
);
|
||||
form.reset();
|
||||
router.push('');
|
||||
} else {
|
||||
setStatusMessage(`Error: ${result.error}`)
|
||||
setStatusMessage(`Error: ${result.error}`);
|
||||
}
|
||||
} catch (error) {
|
||||
setStatusMessage(
|
||||
`Error: ${error instanceof Error ? error.message : 'Could not sign in!'}`
|
||||
`Error: ${error instanceof Error ? error.message : 'Could not sign in!'}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
@ -97,9 +96,7 @@ const SignUp = () => {
|
||||
return (
|
||||
<Card className='min-w-xs md:min-w-sm'>
|
||||
<CardHeader>
|
||||
<CardTitle className='text-3xl font-medium'>
|
||||
Sign Up
|
||||
</CardTitle>
|
||||
<CardTitle className='text-3xl font-medium'>Sign Up</CardTitle>
|
||||
<CardDescription className='text-foreground'>
|
||||
Already have an account?{' '}
|
||||
<Link className='text-primary font-medium underline' href='/sign-in'>
|
||||
@ -109,7 +106,10 @@ const SignUp = () => {
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(handleSignUp)} className='flex flex-col mx-auto space-y-4'>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(handleSignUp)}
|
||||
className='flex flex-col mx-auto space-y-4'
|
||||
>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='name'
|
||||
@ -129,7 +129,11 @@ const SignUp = () => {
|
||||
<FormItem>
|
||||
<FormLabel className='text-lg'>Email</FormLabel>
|
||||
<FormControl>
|
||||
<Input type='email' placeholder='you@example.com' {...field} />
|
||||
<Input
|
||||
type='email'
|
||||
placeholder='you@example.com'
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@ -142,7 +146,11 @@ const SignUp = () => {
|
||||
<FormItem>
|
||||
<FormLabel className='text-lg'>Password</FormLabel>
|
||||
<FormControl>
|
||||
<Input type='password' placeholder='Your password' {...field} />
|
||||
<Input
|
||||
type='password'
|
||||
placeholder='Your password'
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@ -155,20 +163,25 @@ const SignUp = () => {
|
||||
<FormItem>
|
||||
<FormLabel className='text-lg'>Confirm Password</FormLabel>
|
||||
<FormControl>
|
||||
<Input type='password' placeholder='Confirm password' {...field} />
|
||||
<Input
|
||||
type='password'
|
||||
placeholder='Confirm password'
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
{statusMessage && (
|
||||
statusMessage.includes('Error') ||
|
||||
statusMessage.includes('error') ||
|
||||
statusMessage.includes('failed') ||
|
||||
statusMessage.includes('invalid')
|
||||
? <StatusMessage message={{error: statusMessage}} />
|
||||
: <StatusMessage message={{ success: statusMessage }} />
|
||||
)}
|
||||
{statusMessage &&
|
||||
(statusMessage.includes('Error') ||
|
||||
statusMessage.includes('error') ||
|
||||
statusMessage.includes('failed') ||
|
||||
statusMessage.includes('invalid') ? (
|
||||
<StatusMessage message={{ error: statusMessage }} />
|
||||
) : (
|
||||
<StatusMessage message={{ success: statusMessage }} />
|
||||
))}
|
||||
<SubmitButton
|
||||
className='text-[1.0rem] cursor-pointer'
|
||||
disabled={isLoading}
|
||||
|
@ -3,7 +3,7 @@ import '@/styles/globals.css';
|
||||
import { Geist } from 'next/font/google';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { ThemeProvider } from '@/components/context/theme';
|
||||
import { AuthProvider } from '@/components/context/auth'
|
||||
import { AuthProvider } from '@/components/context/auth';
|
||||
import Navigation from '@/components/default/navigation';
|
||||
import Footer from '@/components/default/footer';
|
||||
import { Toaster } from '@/components/ui';
|
||||
@ -15,8 +15,9 @@ export const metadata: Metadata = {
|
||||
},
|
||||
description: 'Created by Gib with T3!',
|
||||
applicationName: 'T3 Template',
|
||||
keywords: 'T3 Template, Next.js, Supabase, Tailwind, TypeScript, React, T3, Gib, Theo',
|
||||
authors: [{name: 'Gib', url: 'https://gbrown.org'}],
|
||||
keywords:
|
||||
'T3 Template, Next.js, Supabase, Tailwind, TypeScript, React, T3, Gib, Theo',
|
||||
authors: [{ name: 'Gib', url: 'https://gbrown.org' }],
|
||||
creator: 'Gib Brown',
|
||||
publisher: 'Gib Brown',
|
||||
formatDetection: {
|
||||
@ -40,40 +41,120 @@ export const metadata: Metadata = {
|
||||
icons: {
|
||||
icon: [
|
||||
{ url: '/favicon.ico', type: 'image/x-icon', sizes: 'any' },
|
||||
{ url: '/favicon-16x16.png', type: 'image/png', sizes: '16x16'},
|
||||
{ url: '/favicon-32x32.png', type: 'image/png', sizes: '32x32'},
|
||||
{ url: '/favicon.png', type: 'image/png', sizes: '96x96'},
|
||||
{ url: '/favicon.ico', type: 'image/x-icon', sizes: 'any', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/favicon-16x16.png', type: 'image/png', sizes: '16x16', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/favicon-32x32.png', type: 'image/png', sizes: '32x32', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/favicon-96x96.png', type: 'image/png', sizes: '96x96', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/favicon-16x16.png', type: 'image/png', sizes: '16x16' },
|
||||
{ url: '/favicon-32x32.png', type: 'image/png', sizes: '32x32' },
|
||||
{ url: '/favicon.png', type: 'image/png', sizes: '96x96' },
|
||||
{
|
||||
url: '/favicon.ico',
|
||||
type: 'image/x-icon',
|
||||
sizes: 'any',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: '/favicon-16x16.png',
|
||||
type: 'image/png',
|
||||
sizes: '16x16',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: '/favicon-32x32.png',
|
||||
type: 'image/png',
|
||||
sizes: '32x32',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: '/favicon-96x96.png',
|
||||
type: 'image/png',
|
||||
sizes: '96x96',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
|
||||
{ url: '/appicon/icon-36x36.png', type: 'image/png', sizes: '36x36'},
|
||||
{ url: '/appicon/icon-48x48.png', type: 'image/png', sizes: '48x48'},
|
||||
{ url: '/appicon/icon-72x72.png', type: 'image/png', sizes: '72x72'},
|
||||
{ url: '/appicon/icon-96x96.png', type: 'image/png', sizes: '96x96'},
|
||||
{ url: '/appicon/icon-144x144.png', type: 'image/png', sizes: '144x144'},
|
||||
{ url: '/appicon/icon.png', type: 'image/png', sizes: '192x192'},
|
||||
{ url: '/appicon/icon-36x36.png', type: 'image/png', sizes: '36x36', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/appicon/icon-48x48.png', type: 'image/png', sizes: '48x48', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/appicon/icon-72x72.png', type: 'image/png', sizes: '72x72', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/appicon/icon-96x96.png', type: 'image/png', sizes: '96x96', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/appicon/icon-144x144.png', type: 'image/png', sizes: '144x144', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/appicon/icon.png', type: 'image/png', sizes: '192x192', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/appicon/icon-36x36.png', type: 'image/png', sizes: '36x36' },
|
||||
{ url: '/appicon/icon-48x48.png', type: 'image/png', sizes: '48x48' },
|
||||
{ url: '/appicon/icon-72x72.png', type: 'image/png', sizes: '72x72' },
|
||||
{ url: '/appicon/icon-96x96.png', type: 'image/png', sizes: '96x96' },
|
||||
{ url: '/appicon/icon-144x144.png', type: 'image/png', sizes: '144x144' },
|
||||
{ url: '/appicon/icon.png', type: 'image/png', sizes: '192x192' },
|
||||
{
|
||||
url: '/appicon/icon-36x36.png',
|
||||
type: 'image/png',
|
||||
sizes: '36x36',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: '/appicon/icon-48x48.png',
|
||||
type: 'image/png',
|
||||
sizes: '48x48',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: '/appicon/icon-72x72.png',
|
||||
type: 'image/png',
|
||||
sizes: '72x72',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: '/appicon/icon-96x96.png',
|
||||
type: 'image/png',
|
||||
sizes: '96x96',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: '/appicon/icon-144x144.png',
|
||||
type: 'image/png',
|
||||
sizes: '144x144',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: '/appicon/icon.png',
|
||||
type: 'image/png',
|
||||
sizes: '192x192',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
],
|
||||
shortcut: [
|
||||
{ url: '/appicon/icon-36x36.png', type: 'image/png', sizes: '36x36'},
|
||||
{ url: '/appicon/icon-48x48.png', type: 'image/png', sizes: '48x48'},
|
||||
{ url: '/appicon/icon-72x72.png', type: 'image/png', sizes: '72x72'},
|
||||
{ url: '/appicon/icon-96x96.png', type: 'image/png', sizes: '96x96'},
|
||||
{ url: '/appicon/icon-144x144.png', type: 'image/png', sizes: '144x144'},
|
||||
{ url: '/appicon/icon.png', type: 'image/png', sizes: '192x192'},
|
||||
{ url: '/appicon/icon-36x36.png', type: 'image/png', sizes: '36x36', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/appicon/icon-48x48.png', type: 'image/png', sizes: '48x48', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/appicon/icon-72x72.png', type: 'image/png', sizes: '72x72', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/appicon/icon-96x96.png', type: 'image/png', sizes: '96x96', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/appicon/icon-144x144.png', type: 'image/png', sizes: '144x144', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/appicon/icon.png', type: 'image/png', sizes: '192x192', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: '/appicon/icon-36x36.png', type: 'image/png', sizes: '36x36' },
|
||||
{ url: '/appicon/icon-48x48.png', type: 'image/png', sizes: '48x48' },
|
||||
{ url: '/appicon/icon-72x72.png', type: 'image/png', sizes: '72x72' },
|
||||
{ url: '/appicon/icon-96x96.png', type: 'image/png', sizes: '96x96' },
|
||||
{ url: '/appicon/icon-144x144.png', type: 'image/png', sizes: '144x144' },
|
||||
{ url: '/appicon/icon.png', type: 'image/png', sizes: '192x192' },
|
||||
{
|
||||
url: '/appicon/icon-36x36.png',
|
||||
type: 'image/png',
|
||||
sizes: '36x36',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: '/appicon/icon-48x48.png',
|
||||
type: 'image/png',
|
||||
sizes: '48x48',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: '/appicon/icon-72x72.png',
|
||||
type: 'image/png',
|
||||
sizes: '72x72',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: '/appicon/icon-96x96.png',
|
||||
type: 'image/png',
|
||||
sizes: '96x96',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: '/appicon/icon-144x144.png',
|
||||
type: 'image/png',
|
||||
sizes: '144x144',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: '/appicon/icon.png',
|
||||
type: 'image/png',
|
||||
sizes: '192x192',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
],
|
||||
apple: [
|
||||
{ url: 'appicon/icon-57x57.png', type: 'image/png', sizes: '57x57' },
|
||||
@ -86,23 +167,73 @@ export const metadata: Metadata = {
|
||||
{ url: 'appicon/icon-152x152.png', type: 'image/png', sizes: '152x152' },
|
||||
{ url: 'appicon/icon-180x180.png', type: 'image/png', sizes: '180x180' },
|
||||
{ url: 'appicon/icon.png', type: 'image/png', sizes: '192x192' },
|
||||
{ url: 'appicon/icon-57x57.png', type: 'image/png', sizes: '57x57', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: 'appicon/icon-60x60.png', type: 'image/png', sizes: '60x60', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: 'appicon/icon-72x72.png', type: 'image/png', sizes: '72x72', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: 'appicon/icon-76x76.png', type: 'image/png', sizes: '76x76', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: 'appicon/icon-114x114.png', type: 'image/png', sizes: '114x114', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: 'appicon/icon-120x120.png', type: 'image/png', sizes: '120x120', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: 'appicon/icon-144x144.png', type: 'image/png', sizes: '144x144', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: 'appicon/icon-152x152.png', type: 'image/png', sizes: '152x152', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: 'appicon/icon-180x180.png', type: 'image/png', sizes: '180x180', media: '(prefers-color-scheme: dark)' },
|
||||
{ url: 'appicon/icon.png', type: 'image/png', sizes: '192x192', media: '(prefers-color-scheme: dark)' },
|
||||
{
|
||||
url: 'appicon/icon-57x57.png',
|
||||
type: 'image/png',
|
||||
sizes: '57x57',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: 'appicon/icon-60x60.png',
|
||||
type: 'image/png',
|
||||
sizes: '60x60',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: 'appicon/icon-72x72.png',
|
||||
type: 'image/png',
|
||||
sizes: '72x72',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: 'appicon/icon-76x76.png',
|
||||
type: 'image/png',
|
||||
sizes: '76x76',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: 'appicon/icon-114x114.png',
|
||||
type: 'image/png',
|
||||
sizes: '114x114',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: 'appicon/icon-120x120.png',
|
||||
type: 'image/png',
|
||||
sizes: '120x120',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: 'appicon/icon-144x144.png',
|
||||
type: 'image/png',
|
||||
sizes: '144x144',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: 'appicon/icon-152x152.png',
|
||||
type: 'image/png',
|
||||
sizes: '152x152',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: 'appicon/icon-180x180.png',
|
||||
type: 'image/png',
|
||||
sizes: '180x180',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
{
|
||||
url: 'appicon/icon.png',
|
||||
type: 'image/png',
|
||||
sizes: '192x192',
|
||||
media: '(prefers-color-scheme: dark)',
|
||||
},
|
||||
],
|
||||
other: [
|
||||
{
|
||||
rel: 'apple-touch-icon-precomposed',
|
||||
url: '/appicon/icon-precomposed.png',
|
||||
type: 'image/png',
|
||||
sizes: '180x180'
|
||||
sizes: '180x180',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -14,11 +14,7 @@ import {
|
||||
getUser,
|
||||
updateProfile as updateProfileAction,
|
||||
} from '@/lib/hooks';
|
||||
import {
|
||||
type User,
|
||||
type Profile,
|
||||
createClient,
|
||||
} from '@/utils/supabase';
|
||||
import { type User, type Profile, createClient } from '@/utils/supabase';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
type AuthContextType = {
|
||||
@ -45,61 +41,64 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
|
||||
const [isInitialized, setIsInitialized] = useState(false);
|
||||
const fetchingRef = useRef(false);
|
||||
|
||||
const fetchUserData = useCallback(async (showLoading = true) => {
|
||||
if (fetchingRef.current) return;
|
||||
fetchingRef.current = true;
|
||||
const fetchUserData = useCallback(
|
||||
async (showLoading = true) => {
|
||||
if (fetchingRef.current) return;
|
||||
fetchingRef.current = true;
|
||||
|
||||
try {
|
||||
// Only show loading for initial load or manual refresh
|
||||
if (showLoading) {
|
||||
setIsLoading(true);
|
||||
}
|
||||
try {
|
||||
// Only show loading for initial load or manual refresh
|
||||
if (showLoading) {
|
||||
setIsLoading(true);
|
||||
}
|
||||
|
||||
const userResponse = await getUser();
|
||||
const profileResponse = await getProfile();
|
||||
const userResponse = await getUser();
|
||||
const profileResponse = await getProfile();
|
||||
|
||||
if (!userResponse.success || !profileResponse.success) {
|
||||
setUser(null);
|
||||
setProfile(null);
|
||||
setAvatarUrl(null);
|
||||
return;
|
||||
}
|
||||
if (!userResponse.success || !profileResponse.success) {
|
||||
setUser(null);
|
||||
setProfile(null);
|
||||
setAvatarUrl(null);
|
||||
return;
|
||||
}
|
||||
|
||||
setUser(userResponse.data);
|
||||
setProfile(profileResponse.data);
|
||||
setUser(userResponse.data);
|
||||
setProfile(profileResponse.data);
|
||||
|
||||
// Get avatar URL if available
|
||||
if (profileResponse.data.avatar_url) {
|
||||
const avatarResponse = await getSignedUrl({
|
||||
bucket: 'avatars',
|
||||
url: profileResponse.data.avatar_url,
|
||||
});
|
||||
if (avatarResponse.success) {
|
||||
setAvatarUrl(avatarResponse.data);
|
||||
// Get avatar URL if available
|
||||
if (profileResponse.data.avatar_url) {
|
||||
const avatarResponse = await getSignedUrl({
|
||||
bucket: 'avatars',
|
||||
url: profileResponse.data.avatar_url,
|
||||
});
|
||||
if (avatarResponse.success) {
|
||||
setAvatarUrl(avatarResponse.data);
|
||||
} else {
|
||||
setAvatarUrl(null);
|
||||
}
|
||||
} else {
|
||||
setAvatarUrl(null);
|
||||
}
|
||||
} else {
|
||||
setAvatarUrl(null);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
'Auth fetch error: ',
|
||||
error instanceof Error
|
||||
? `${error.message}`
|
||||
: 'Failed to load user data!',
|
||||
);
|
||||
if (!isInitialized) {
|
||||
toast.error('Failed to load user data!');
|
||||
}
|
||||
} finally {
|
||||
if (showLoading) {
|
||||
setIsLoading(false);
|
||||
}
|
||||
setIsInitialized(true);
|
||||
fetchingRef.current = false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
'Auth fetch error: ',
|
||||
error instanceof Error ?
|
||||
`${error.message}` :
|
||||
'Failed to load user data!'
|
||||
);
|
||||
if (!isInitialized) {
|
||||
toast.error('Failed to load user data!');
|
||||
}
|
||||
} finally {
|
||||
if (showLoading) {
|
||||
setIsLoading(false);
|
||||
}
|
||||
setIsInitialized(true);
|
||||
fetchingRef.current = false;
|
||||
}
|
||||
}, [isInitialized]);
|
||||
},
|
||||
[isInitialized],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const supabase = createClient();
|
||||
@ -133,37 +132,42 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
|
||||
};
|
||||
}, [fetchUserData]);
|
||||
|
||||
const updateProfile = useCallback(async (data: {
|
||||
full_name?: string;
|
||||
email?: string;
|
||||
avatar_url?: string;
|
||||
}) => {
|
||||
try {
|
||||
const result = await updateProfileAction(data);
|
||||
if (!result.success) {
|
||||
throw new Error(result.error ?? 'Failed to update profile');
|
||||
}
|
||||
setProfile(result.data);
|
||||
|
||||
// If avatar was updated, refresh the avatar URL
|
||||
if (data.avatar_url && result.data.avatar_url) {
|
||||
const avatarResponse = await getSignedUrl({
|
||||
bucket: 'avatars',
|
||||
url: result.data.avatar_url,
|
||||
transform: { width: 128, height: 128 },
|
||||
});
|
||||
if (avatarResponse.success) {
|
||||
setAvatarUrl(avatarResponse.data);
|
||||
const updateProfile = useCallback(
|
||||
async (data: {
|
||||
full_name?: string;
|
||||
email?: string;
|
||||
avatar_url?: string;
|
||||
}) => {
|
||||
try {
|
||||
const result = await updateProfileAction(data);
|
||||
if (!result.success) {
|
||||
throw new Error(result.error ?? 'Failed to update profile');
|
||||
}
|
||||
setProfile(result.data);
|
||||
|
||||
// If avatar was updated, refresh the avatar URL
|
||||
if (data.avatar_url && result.data.avatar_url) {
|
||||
const avatarResponse = await getSignedUrl({
|
||||
bucket: 'avatars',
|
||||
url: result.data.avatar_url,
|
||||
transform: { width: 128, height: 128 },
|
||||
});
|
||||
if (avatarResponse.success) {
|
||||
setAvatarUrl(avatarResponse.data);
|
||||
}
|
||||
}
|
||||
toast.success('Profile updated successfully!');
|
||||
return { success: true, data: result.data };
|
||||
} catch (error) {
|
||||
console.error('Error updating profile:', error);
|
||||
toast.error(
|
||||
error instanceof Error ? error.message : 'Failed to update profile',
|
||||
);
|
||||
return { success: false, error };
|
||||
}
|
||||
toast.success('Profile updated successfully!');
|
||||
return { success: true, data: result.data };
|
||||
} catch (error) {
|
||||
console.error('Error updating profile:', error);
|
||||
toast.error(error instanceof Error ? error.message : 'Failed to update profile');
|
||||
return { success: false, error };
|
||||
}
|
||||
}, []);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const refreshUserData = useCallback(async () => {
|
||||
await fetchUserData(true); // Manual refresh shows loading
|
||||
@ -179,11 +183,7 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
|
||||
refreshUserData,
|
||||
};
|
||||
|
||||
return (
|
||||
<AuthContext.Provider value={value}>
|
||||
{children}
|
||||
</AuthContext.Provider>
|
||||
);
|
||||
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
|
||||
};
|
||||
|
||||
export const useAuth = () => {
|
||||
|
@ -15,9 +15,7 @@ export const StatusMessage = ({ message }: { message: Message }) => {
|
||||
</div>
|
||||
)}
|
||||
{'error' in message && (
|
||||
<div className='text-destructive'>
|
||||
{message.error}
|
||||
</div>
|
||||
<div className='text-destructive'>{message.error}</div>
|
||||
)}
|
||||
{'message' in message && (
|
||||
<div className='text-foreground'>{message.message}</div>
|
||||
|
@ -28,7 +28,7 @@ export const SignInWithApple = () => {
|
||||
}
|
||||
} catch (error) {
|
||||
setStatusMessage(
|
||||
`Error: ${error instanceof Error ? error.message : 'Could not sign in!'}`
|
||||
`Error: ${error instanceof Error ? error.message : 'Could not sign in!'}`,
|
||||
);
|
||||
} finally {
|
||||
setIsSigningIn(false);
|
||||
@ -38,28 +38,25 @@ export const SignInWithApple = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<form
|
||||
onSubmit={handleSignInWithApple}
|
||||
className='my-4'
|
||||
>
|
||||
<form onSubmit={handleSignInWithApple} className='my-4'>
|
||||
<SubmitButton
|
||||
className='w-full cursor-pointer'
|
||||
disabled={isLoading || isSigningIn}
|
||||
pendingText='Redirecting...'
|
||||
type="submit"
|
||||
type='submit'
|
||||
>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Image src='/icons/apple.svg'
|
||||
<Image
|
||||
src='/icons/apple.svg'
|
||||
alt='Apple logo'
|
||||
className='invert-75 dark:invert-25'
|
||||
width={22} height={22}
|
||||
width={22}
|
||||
height={22}
|
||||
/>
|
||||
<p className='text-[1.0rem]'>Sign in with Apple</p>
|
||||
</div>
|
||||
</SubmitButton>
|
||||
{statusMessage && (
|
||||
<StatusMessage message={{ error: statusMessage }} />
|
||||
)}
|
||||
{statusMessage && <StatusMessage message={{ error: statusMessage }} />}
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
@ -26,30 +26,30 @@ export const SignInWithMicrosoft = () => {
|
||||
}
|
||||
} catch (error) {
|
||||
setStatusMessage(
|
||||
`Error: ${error instanceof Error ? error.message : 'Could not sign in!'}`
|
||||
`Error: ${error instanceof Error ? error.message : 'Could not sign in!'}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<form
|
||||
onSubmit={handleSignInWithMicrosoft}
|
||||
className='my-4'
|
||||
>
|
||||
<form onSubmit={handleSignInWithMicrosoft} className='my-4'>
|
||||
<SubmitButton
|
||||
className='w-full cursor-pointer'
|
||||
disabled={isLoading || isSigningIn}
|
||||
pendingText='Redirecting...'
|
||||
type="submit"
|
||||
type='submit'
|
||||
>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Image src='/icons/microsoft.svg' alt='Microsoft logo' width={20} height={20} />
|
||||
<Image
|
||||
src='/icons/microsoft.svg'
|
||||
alt='Microsoft logo'
|
||||
width={20}
|
||||
height={20}
|
||||
/>
|
||||
<p className='text-[1.0rem]'>Sign in with Microsoft</p>
|
||||
</div>
|
||||
</SubmitButton>
|
||||
{statusMessage && (
|
||||
<StatusMessage message={{ error: statusMessage }} />
|
||||
)}
|
||||
{statusMessage && <StatusMessage message={{ error: statusMessage }} />}
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
@ -1,2 +1,5 @@
|
||||
export { StatusMessage, type Message } from '@/components/default/StatusMessage';
|
||||
export {
|
||||
StatusMessage,
|
||||
type Message,
|
||||
} from '@/components/default/StatusMessage';
|
||||
export { SubmitButton } from '@/components/default/SubmitButton';
|
||||
|
@ -31,7 +31,8 @@ const AvatarDropdown = () => {
|
||||
|
||||
const getInitials = (name: string | null | undefined): string => {
|
||||
if (!name) return '';
|
||||
return name.split(' ')
|
||||
return name
|
||||
.split(' ')
|
||||
.map((n) => n[0])
|
||||
.join('')
|
||||
.toUpperCase();
|
||||
@ -42,12 +43,19 @@ const AvatarDropdown = () => {
|
||||
<DropdownMenuTrigger>
|
||||
<Avatar className='cursor-pointer'>
|
||||
{avatarUrl ? (
|
||||
<AvatarImage src={avatarUrl} alt={getInitials(profile?.full_name)} width={64} height={64} />
|
||||
<AvatarImage
|
||||
src={avatarUrl}
|
||||
alt={getInitials(profile?.full_name)}
|
||||
width={64}
|
||||
height={64}
|
||||
/>
|
||||
) : (
|
||||
<AvatarFallback className='text-sm'>
|
||||
{profile?.full_name
|
||||
? getInitials(profile.full_name)
|
||||
: <User size={32} />}
|
||||
{profile?.full_name ? (
|
||||
getInitials(profile.full_name)
|
||||
) : (
|
||||
<User size={32} />
|
||||
)}
|
||||
</AvatarFallback>
|
||||
)}
|
||||
</Avatar>
|
||||
@ -56,13 +64,19 @@ const AvatarDropdown = () => {
|
||||
<DropdownMenuLabel>{profile?.full_name}</DropdownMenuLabel>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href='/profile' className='w-full justify-center cursor-pointer'>
|
||||
<Link
|
||||
href='/profile'
|
||||
className='w-full justify-center cursor-pointer'
|
||||
>
|
||||
Edit profile
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator className='h-[2px]' />
|
||||
<DropdownMenuItem asChild>
|
||||
<button onClick={handleSignOut} className='w-full justify-center cursor-pointer'>
|
||||
<button
|
||||
onClick={handleSignOut}
|
||||
className='w-full justify-center cursor-pointer'
|
||||
>
|
||||
Log out
|
||||
</button>
|
||||
</DropdownMenuItem>
|
||||
|
@ -1,6 +1,11 @@
|
||||
import { useFileUpload } from '@/lib/hooks/useFileUpload';
|
||||
import { useAuth } from '@/components/context/auth';
|
||||
import { Avatar, AvatarFallback, AvatarImage, CardContent } from '@/components/ui';
|
||||
import {
|
||||
Avatar,
|
||||
AvatarFallback,
|
||||
AvatarImage,
|
||||
CardContent,
|
||||
} from '@/components/ui';
|
||||
import { Loader2, Pencil, Upload, User } from 'lucide-react';
|
||||
|
||||
type AvatarUploadProps = {
|
||||
@ -28,16 +33,17 @@ export const AvatarUpload = ({ onAvatarUploaded }: AvatarUploadProps) => {
|
||||
maxHeight: 500,
|
||||
quality: 0.8,
|
||||
},
|
||||
replace: {replace: true, path: profile?.avatar_url ?? file.name},
|
||||
replace: { replace: true, path: profile?.avatar_url ?? file.name },
|
||||
});
|
||||
if (result.success && result.path) {
|
||||
await onAvatarUploaded(result.path);
|
||||
if (result.success && result.data) {
|
||||
await onAvatarUploaded(result.data);
|
||||
}
|
||||
};
|
||||
|
||||
const getInitials = (name: string | null | undefined): string => {
|
||||
if (!name) return '';
|
||||
return name.split(' ')
|
||||
return name
|
||||
.split(' ')
|
||||
.map((n) => n[0])
|
||||
.join('')
|
||||
.toUpperCase();
|
||||
@ -45,23 +51,29 @@ export const AvatarUpload = ({ onAvatarUploaded }: AvatarUploadProps) => {
|
||||
|
||||
return (
|
||||
<CardContent>
|
||||
|
||||
<div className='flex flex-col items-center'>
|
||||
<div
|
||||
className='relative group cursor-pointer mb-4'
|
||||
onClick={handleAvatarClick}
|
||||
>
|
||||
<Avatar className='h-32 w-32'>
|
||||
{avatarUrl ? (
|
||||
<AvatarImage src={avatarUrl} alt={getInitials(profile?.full_name)} width={128} height={128} />
|
||||
) : (
|
||||
<AvatarFallback className='text-4xl'>
|
||||
{profile?.full_name
|
||||
? getInitials(profile.full_name)
|
||||
: <User size={32} />}
|
||||
</AvatarFallback>
|
||||
)}
|
||||
</Avatar>
|
||||
<div className='flex flex-col items-center'>
|
||||
<div
|
||||
className='relative group cursor-pointer mb-4'
|
||||
onClick={handleAvatarClick}
|
||||
>
|
||||
<Avatar className='h-32 w-32'>
|
||||
{avatarUrl ? (
|
||||
<AvatarImage
|
||||
src={avatarUrl}
|
||||
alt={getInitials(profile?.full_name)}
|
||||
width={128}
|
||||
height={128}
|
||||
/>
|
||||
) : (
|
||||
<AvatarFallback className='text-4xl'>
|
||||
{profile?.full_name ? (
|
||||
getInitials(profile.full_name)
|
||||
) : (
|
||||
<User size={32} />
|
||||
)}
|
||||
</AvatarFallback>
|
||||
)}
|
||||
</Avatar>
|
||||
<div
|
||||
className='absolute inset-0 rounded-full bg-black/0 group-hover:bg-black/50
|
||||
transition-all flex items-center justify-center'
|
||||
@ -88,13 +100,13 @@ export const AvatarUpload = ({ onAvatarUploaded }: AvatarUploadProps) => {
|
||||
onChange={handleFileChange}
|
||||
disabled={isUploading}
|
||||
/>
|
||||
{isUploading && (
|
||||
<div className='flex items-center text-sm text-gray-500 mt-2'>
|
||||
<Loader2 className='h-4 w-4 mr-2 animate-spin' />
|
||||
Uploading...
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{isUploading && (
|
||||
<div className='flex items-center text-sm text-gray-500 mt-2'>
|
||||
<Loader2 className='h-4 w-4 mr-2 animate-spin' />
|
||||
Uploading...
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
);
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ type ProfileFormProps = {
|
||||
onSubmit: (values: z.infer<typeof formSchema>) => Promise<void>;
|
||||
};
|
||||
|
||||
export const ProfileForm = ({onSubmit}: ProfileFormProps) => {
|
||||
export const ProfileForm = ({ onSubmit }: ProfileFormProps) => {
|
||||
const { profile, isLoading } = useAuth();
|
||||
|
||||
const form = useForm<z.infer<typeof formSchema>>({
|
||||
@ -89,10 +89,7 @@ export const ProfileForm = ({onSubmit}: ProfileFormProps) => {
|
||||
/>
|
||||
|
||||
<div className='flex justify-center'>
|
||||
<SubmitButton
|
||||
disabled={isLoading}
|
||||
pendingText='Saving...'
|
||||
>
|
||||
<SubmitButton disabled={isLoading} pendingText='Saving...'>
|
||||
Save Changes
|
||||
</SubmitButton>
|
||||
</div>
|
||||
@ -100,4 +97,4 @@ export const ProfileForm = ({onSubmit}: ProfileFormProps) => {
|
||||
</Form>
|
||||
</CardContent>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -69,7 +69,7 @@ export const ResetPasswordForm = ({
|
||||
}
|
||||
} catch (error) {
|
||||
setStatusMessage(
|
||||
error instanceof Error ? error.message : 'Password was not updated!'
|
||||
error instanceof Error ? error.message : 'Password was not updated!',
|
||||
);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
@ -125,7 +125,8 @@ export const ResetPasswordForm = ({
|
||||
{statusMessage && (
|
||||
<div
|
||||
className={`text-sm text-center ${
|
||||
statusMessage.includes('Error') || statusMessage.includes('failed')
|
||||
statusMessage.includes('Error') ||
|
||||
statusMessage.includes('failed')
|
||||
? 'text-destructive'
|
||||
: 'text-green-600'
|
||||
}`}
|
||||
|
@ -1,13 +1,14 @@
|
||||
'use server';
|
||||
|
||||
import 'server-only';
|
||||
import { encodedRedirect } from '@/utils/utils';
|
||||
import { createServerClient } from '@/utils/supabase';
|
||||
import { headers } from 'next/headers';
|
||||
import type { User } from '@/utils/supabase';
|
||||
import type { Result } from './index';
|
||||
import type { Result } from '.';
|
||||
|
||||
export const signUp = async (formData: FormData): Promise<Result<string | null>> => {
|
||||
export const signUp = async (
|
||||
formData: FormData,
|
||||
): Promise<Result<string | null>> => {
|
||||
const name = formData.get('name') as string;
|
||||
const email = formData.get('email') as string;
|
||||
const password = formData.get('password') as string;
|
||||
@ -15,11 +16,7 @@ export const signUp = async (formData: FormData): Promise<Result<string | null>>
|
||||
const origin = (await headers()).get('origin');
|
||||
|
||||
if (!email || !password) {
|
||||
return encodedRedirect(
|
||||
'error',
|
||||
'/sign-up',
|
||||
'Email & password are required',
|
||||
);
|
||||
return { success: false, error: 'Email and password are required' };
|
||||
}
|
||||
|
||||
const { error } = await supabase.auth.signUp({
|
||||
@ -34,6 +31,7 @@ export const signUp = async (formData: FormData): Promise<Result<string | null>>
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (error) {
|
||||
return { success: false, error: error.message };
|
||||
} else {
|
||||
@ -44,9 +42,7 @@ export const signUp = async (formData: FormData): Promise<Result<string | null>>
|
||||
}
|
||||
};
|
||||
|
||||
export const signIn = async (
|
||||
formData: FormData,
|
||||
): Promise<Result<null>> => {
|
||||
export const signIn = async (formData: FormData): Promise<Result<null>> => {
|
||||
const email = formData.get('email') as string;
|
||||
const password = formData.get('password') as string;
|
||||
const supabase = await createServerClient();
|
||||
@ -68,10 +64,10 @@ export const signInWithMicrosoft = async (): Promise<Result<string>> => {
|
||||
provider: 'azure',
|
||||
options: {
|
||||
scopes: 'openid, profile email offline_access',
|
||||
}
|
||||
},
|
||||
});
|
||||
if (error) return { success: false, error: error.message };
|
||||
return { success: true, data: data.url};
|
||||
return { success: true, data: data.url };
|
||||
};
|
||||
|
||||
export const signInWithApple = async (): Promise<Result<string>> => {
|
||||
@ -80,13 +76,15 @@ export const signInWithApple = async (): Promise<Result<string>> => {
|
||||
provider: 'apple',
|
||||
options: {
|
||||
scopes: 'openid, profile email offline_access',
|
||||
}
|
||||
},
|
||||
});
|
||||
if (error) return { success: false, error: error.message };
|
||||
return { success: true, data: data.url};
|
||||
return { success: true, data: data.url };
|
||||
};
|
||||
|
||||
export const forgotPassword = async (formData: FormData): Promise<Result<string | null>> => {
|
||||
export const forgotPassword = async (
|
||||
formData: FormData,
|
||||
): Promise<Result<string | null>> => {
|
||||
const email = formData.get('email') as string;
|
||||
const supabase = await createServerClient();
|
||||
const origin = (await headers()).get('origin');
|
||||
@ -102,15 +100,22 @@ export const forgotPassword = async (formData: FormData): Promise<Result<string
|
||||
if (error) {
|
||||
return { success: false, error: 'Could not reset password' };
|
||||
}
|
||||
return { success: true, data: 'Check your email for a link to reset your password.' };
|
||||
return {
|
||||
success: true,
|
||||
data: 'Check your email for a link to reset your password.',
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
export const resetPassword = async (formData: FormData): Promise<Result<null>> => {
|
||||
export const resetPassword = async (
|
||||
formData: FormData,
|
||||
): Promise<Result<null>> => {
|
||||
const password = formData.get('password') as string;
|
||||
const confirmPassword = formData.get('confirmPassword') as string;
|
||||
if (!password || !confirmPassword) {
|
||||
return { success: false, error: 'Password and confirm password are required!' };
|
||||
return {
|
||||
success: false,
|
||||
error: 'Password and confirm password are required!',
|
||||
};
|
||||
}
|
||||
const supabase = await createServerClient();
|
||||
if (password !== confirmPassword) {
|
||||
@ -120,7 +125,10 @@ export const resetPassword = async (formData: FormData): Promise<Result<null>> =
|
||||
password,
|
||||
});
|
||||
if (error) {
|
||||
return { success: false, error: `Password update failed: ${error.message}` };
|
||||
return {
|
||||
success: false,
|
||||
error: `Password update failed: ${error.message}`,
|
||||
};
|
||||
}
|
||||
return { success: true, data: null };
|
||||
};
|
||||
@ -128,7 +136,7 @@ export const resetPassword = async (formData: FormData): Promise<Result<null>> =
|
||||
export const signOut = async (): Promise<Result<null>> => {
|
||||
const supabase = await createServerClient();
|
||||
const { error } = await supabase.auth.signOut();
|
||||
if (error) return { success: false, error: error.message }
|
||||
if (error) return { success: false, error: error.message };
|
||||
return { success: true, data: null };
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
import 'server-only';
|
||||
import { createServerClient, type Profile } from '@/utils/supabase';
|
||||
import { getUser } from '@/lib/actions';
|
||||
import type { Result } from './index';
|
||||
import type { Result } from '.';
|
||||
|
||||
export const getProfile = async (): Promise<Result<Profile>> => {
|
||||
try {
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use server';
|
||||
import 'server-only';
|
||||
import { createServerClient } from '@/utils/supabase';
|
||||
import type { Result } from './index';
|
||||
import type { Result } from '.';
|
||||
|
||||
export type GetStorageProps = {
|
||||
bucket: string;
|
||||
@ -38,12 +38,12 @@ export type ReplaceStorageProps = {
|
||||
};
|
||||
|
||||
export type resizeImageProps = {
|
||||
file: File,
|
||||
file: File;
|
||||
options?: {
|
||||
maxWidth?: number,
|
||||
maxHeight?: number,
|
||||
quality?: number,
|
||||
}
|
||||
maxWidth?: number;
|
||||
maxHeight?: number;
|
||||
quality?: number;
|
||||
};
|
||||
};
|
||||
|
||||
export const getSignedUrl = async ({
|
||||
@ -75,7 +75,7 @@ export const getSignedUrl = async ({
|
||||
: 'Unknown error getting signed URL',
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const getPublicUrl = async ({
|
||||
bucket,
|
||||
@ -85,12 +85,10 @@ export const getPublicUrl = async ({
|
||||
}: GetStorageProps): Promise<Result<string>> => {
|
||||
try {
|
||||
const supabase = await createServerClient();
|
||||
const { data } = supabase.storage
|
||||
.from(bucket)
|
||||
.getPublicUrl(url, {
|
||||
download,
|
||||
transform,
|
||||
});
|
||||
const { data } = supabase.storage.from(bucket).getPublicUrl(url, {
|
||||
download,
|
||||
transform,
|
||||
});
|
||||
|
||||
if (!data?.publicUrl) throw new Error('No public URL returned');
|
||||
|
||||
@ -104,7 +102,7 @@ export const getPublicUrl = async ({
|
||||
: 'Unknown error getting public URL',
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const uploadFile = async ({
|
||||
bucket,
|
||||
@ -129,7 +127,7 @@ export const uploadFile = async ({
|
||||
error instanceof Error ? error.message : 'Unknown error uploading file',
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const replaceFile = async ({
|
||||
bucket,
|
||||
@ -141,7 +139,7 @@ export const replaceFile = async ({
|
||||
const supabase = await createServerClient();
|
||||
const { data, error } = await supabase.storage
|
||||
.from(bucket)
|
||||
.update(path, file, {...options, upsert: true});
|
||||
.update(path, file, { ...options, upsert: true });
|
||||
if (error) throw error;
|
||||
if (!data?.path) throw new Error('No path returned from upload');
|
||||
return { success: true, data: data.path };
|
||||
@ -176,7 +174,7 @@ export const deleteFile = async ({
|
||||
error instanceof Error ? error.message : 'Unknown error deleting file',
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Add a helper to list files in a bucket
|
||||
export const listFiles = async ({
|
||||
@ -210,53 +208,49 @@ export const listFiles = async ({
|
||||
error instanceof Error ? error.message : 'Unknown error listing files',
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const resizeImage = async ({
|
||||
file,
|
||||
options = {},
|
||||
}: resizeImageProps): Promise<File> => {
|
||||
const {
|
||||
maxWidth = 800,
|
||||
maxHeight = 800,
|
||||
quality = 0.8,
|
||||
} = options;
|
||||
return new Promise((resolve) => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = (event) => {
|
||||
const img = new Image();
|
||||
img.src = event.target?.result as string;
|
||||
img.onload = () => {
|
||||
let width = img.width;
|
||||
let height = img.height;
|
||||
if (width > height) {
|
||||
if (width > maxWidth) {
|
||||
height = Math.round((height * maxWidth / width));
|
||||
width = maxWidth;
|
||||
}
|
||||
} else if (height > maxHeight) {
|
||||
width = Math.round((width * maxHeight / height));
|
||||
height = maxHeight;
|
||||
const { maxWidth = 800, maxHeight = 800, quality = 0.8 } = options;
|
||||
return new Promise((resolve) => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = (event) => {
|
||||
const img = new Image();
|
||||
img.src = event.target?.result as string;
|
||||
img.onload = () => {
|
||||
let width = img.width;
|
||||
let height = img.height;
|
||||
if (width > height) {
|
||||
if (width > maxWidth) {
|
||||
height = Math.round((height * maxWidth) / width);
|
||||
width = maxWidth;
|
||||
}
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx?.drawImage(img, 0, 0, width, height);
|
||||
canvas.toBlob(
|
||||
(blob) => {
|
||||
if (!blob) return;
|
||||
const resizedFile = new File([blob], file.name, {
|
||||
type: 'imgage/jpeg',
|
||||
lastModified: Date.now(),
|
||||
});
|
||||
resolve(resizedFile);
|
||||
},
|
||||
'image/jpeg',
|
||||
quality
|
||||
);
|
||||
};
|
||||
} else if (height > maxHeight) {
|
||||
width = Math.round((width * maxHeight) / height);
|
||||
height = maxHeight;
|
||||
}
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx?.drawImage(img, 0, 0, width, height);
|
||||
canvas.toBlob(
|
||||
(blob) => {
|
||||
if (!blob) return;
|
||||
const resizedFile = new File([blob], file.name, {
|
||||
type: 'imgage/jpeg',
|
||||
lastModified: Date.now(),
|
||||
});
|
||||
resolve(resizedFile);
|
||||
},
|
||||
'image/jpeg',
|
||||
quality,
|
||||
);
|
||||
};
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
||||
|
@ -1,11 +1,11 @@
|
||||
'use client'
|
||||
import { encodedRedirect } from '@/utils/utils';
|
||||
'use client';
|
||||
import { createClient } from '@/utils/supabase';
|
||||
import type { User } from '@/utils/supabase';
|
||||
import type { Result } from './index';
|
||||
import type { Result } from '.';
|
||||
|
||||
|
||||
export const signUp = async (formData: FormData): Promise<Result<string | null>> => {
|
||||
export const signUp = async (
|
||||
formData: FormData,
|
||||
): Promise<Result<string | null>> => {
|
||||
const name = formData.get('name') as string;
|
||||
const email = formData.get('email') as string;
|
||||
const password = formData.get('password') as string;
|
||||
@ -13,11 +13,7 @@ export const signUp = async (formData: FormData): Promise<Result<string | null>>
|
||||
const origin = process.env.NEXT_PUBLIC_SITE_URL!;
|
||||
|
||||
if (!email || !password) {
|
||||
return encodedRedirect(
|
||||
'error',
|
||||
'/sign-up',
|
||||
'Email & password are required',
|
||||
);
|
||||
return { success: false, error: 'Email and password are required' };
|
||||
}
|
||||
|
||||
const { error } = await supabase.auth.signUp({
|
||||
@ -42,9 +38,7 @@ export const signUp = async (formData: FormData): Promise<Result<string | null>>
|
||||
}
|
||||
};
|
||||
|
||||
export const signIn = async (
|
||||
formData: FormData,
|
||||
): Promise<Result<null>> => {
|
||||
export const signIn = async (formData: FormData): Promise<Result<null>> => {
|
||||
const email = formData.get('email') as string;
|
||||
const password = formData.get('password') as string;
|
||||
const supabase = createClient();
|
||||
@ -60,17 +54,16 @@ export const signIn = async (
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const signInWithMicrosoft = async (): Promise<Result<string>> => {
|
||||
const supabase = createClient();
|
||||
const { data, error } = await supabase.auth.signInWithOAuth({
|
||||
provider: 'azure',
|
||||
options: {
|
||||
scopes: 'openid, profile email offline_access',
|
||||
}
|
||||
},
|
||||
});
|
||||
if (error) return { success: false, error: error.message };
|
||||
return { success: true, data: data.url};
|
||||
return { success: true, data: data.url };
|
||||
};
|
||||
|
||||
export const signInWithApple = async (): Promise<Result<string>> => {
|
||||
@ -79,13 +72,15 @@ export const signInWithApple = async (): Promise<Result<string>> => {
|
||||
provider: 'apple',
|
||||
options: {
|
||||
scopes: 'openid, profile email offline_access',
|
||||
}
|
||||
},
|
||||
});
|
||||
if (error) return { success: false, error: error.message };
|
||||
return { success: true, data: data.url};
|
||||
return { success: true, data: data.url };
|
||||
};
|
||||
|
||||
export const forgotPassword = async (formData: FormData): Promise<Result<string | null>> => {
|
||||
export const forgotPassword = async (
|
||||
formData: FormData,
|
||||
): Promise<Result<string | null>> => {
|
||||
const email = formData.get('email') as string;
|
||||
const supabase = createClient();
|
||||
const origin = process.env.NEXT_PUBLIC_SITE_URL!;
|
||||
@ -101,15 +96,22 @@ export const forgotPassword = async (formData: FormData): Promise<Result<string
|
||||
if (error) {
|
||||
return { success: false, error: 'Could not reset password' };
|
||||
}
|
||||
return { success: true, data: 'Check your email for a link to reset your password.' };
|
||||
return {
|
||||
success: true,
|
||||
data: 'Check your email for a link to reset your password.',
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
export const resetPassword = async (formData: FormData): Promise<Result<null>> => {
|
||||
export const resetPassword = async (
|
||||
formData: FormData,
|
||||
): Promise<Result<null>> => {
|
||||
const password = formData.get('password') as string;
|
||||
const confirmPassword = formData.get('confirmPassword') as string;
|
||||
if (!password || !confirmPassword) {
|
||||
return { success: false, error: 'Password and confirm password are required!' };
|
||||
return {
|
||||
success: false,
|
||||
error: 'Password and confirm password are required!',
|
||||
};
|
||||
}
|
||||
const supabase = createClient();
|
||||
if (password !== confirmPassword) {
|
||||
@ -119,7 +121,10 @@ export const resetPassword = async (formData: FormData): Promise<Result<null>> =
|
||||
password,
|
||||
});
|
||||
if (error) {
|
||||
return { success: false, error: `Password update failed: ${error.message}` };
|
||||
return {
|
||||
success: false,
|
||||
error: `Password update failed: ${error.message}`,
|
||||
};
|
||||
}
|
||||
return { success: true, data: null };
|
||||
};
|
||||
@ -127,7 +132,7 @@ export const resetPassword = async (formData: FormData): Promise<Result<null>> =
|
||||
export const signOut = async (): Promise<Result<null>> => {
|
||||
const supabase = createClient();
|
||||
const { error } = await supabase.auth.signOut();
|
||||
if (error) return { success: false, error: error.message }
|
||||
if (error) return { success: false, error: error.message };
|
||||
return { success: true, data: null };
|
||||
};
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import { createClient, type Profile } from '@/utils/supabase';
|
||||
import { getUser } from '@/lib/hooks';
|
||||
import type { Result } from './index';
|
||||
import type { Result } from '.';
|
||||
|
||||
export const getProfile = async (): Promise<Result<Profile>> => {
|
||||
try {
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { createClient } from '@/utils/supabase';
|
||||
import type { Result } from './index';
|
||||
import type { Result } from '.';
|
||||
|
||||
export type GetStorageProps = {
|
||||
bucket: string;
|
||||
@ -38,12 +38,12 @@ export type ReplaceStorageProps = {
|
||||
};
|
||||
|
||||
export type resizeImageProps = {
|
||||
file: File,
|
||||
file: File;
|
||||
options?: {
|
||||
maxWidth?: number,
|
||||
maxHeight?: number,
|
||||
quality?: number,
|
||||
}
|
||||
maxWidth?: number;
|
||||
maxHeight?: number;
|
||||
quality?: number;
|
||||
};
|
||||
};
|
||||
|
||||
export const getSignedUrl = async ({
|
||||
@ -75,7 +75,7 @@ export const getSignedUrl = async ({
|
||||
: 'Unknown error getting signed URL',
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const getPublicUrl = async ({
|
||||
bucket,
|
||||
@ -85,12 +85,10 @@ export const getPublicUrl = async ({
|
||||
}: GetStorageProps): Promise<Result<string>> => {
|
||||
try {
|
||||
const supabase = createClient();
|
||||
const { data } = supabase.storage
|
||||
.from(bucket)
|
||||
.getPublicUrl(url, {
|
||||
download,
|
||||
transform,
|
||||
});
|
||||
const { data } = supabase.storage.from(bucket).getPublicUrl(url, {
|
||||
download,
|
||||
transform,
|
||||
});
|
||||
|
||||
if (!data?.publicUrl) throw new Error('No public URL returned');
|
||||
|
||||
@ -104,7 +102,7 @@ export const getPublicUrl = async ({
|
||||
: 'Unknown error getting public URL',
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const uploadFile = async ({
|
||||
bucket,
|
||||
@ -129,7 +127,7 @@ export const uploadFile = async ({
|
||||
error instanceof Error ? error.message : 'Unknown error uploading file',
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const replaceFile = async ({
|
||||
bucket,
|
||||
@ -179,7 +177,7 @@ export const deleteFile = async ({
|
||||
error instanceof Error ? error.message : 'Unknown error deleting file',
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Add a helper to list files in a bucket
|
||||
export const listFiles = async ({
|
||||
@ -213,53 +211,49 @@ export const listFiles = async ({
|
||||
error instanceof Error ? error.message : 'Unknown error listing files',
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const resizeImage = async ({
|
||||
file,
|
||||
options = {},
|
||||
}: resizeImageProps): Promise<File> => {
|
||||
const {
|
||||
maxWidth = 800,
|
||||
maxHeight = 800,
|
||||
quality = 0.8,
|
||||
} = options;
|
||||
return new Promise((resolve) => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = (event) => {
|
||||
const img = new Image();
|
||||
img.src = event.target?.result as string;
|
||||
img.onload = () => {
|
||||
let width = img.width;
|
||||
let height = img.height;
|
||||
if (width > height) {
|
||||
if (width > maxWidth) {
|
||||
height = Math.round((height * maxWidth / width));
|
||||
width = maxWidth;
|
||||
}
|
||||
} else if (height > maxHeight) {
|
||||
width = Math.round((width * maxHeight / height));
|
||||
height = maxHeight;
|
||||
const { maxWidth = 800, maxHeight = 800, quality = 0.8 } = options;
|
||||
return new Promise((resolve) => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = (event) => {
|
||||
const img = new Image();
|
||||
img.src = event.target?.result as string;
|
||||
img.onload = () => {
|
||||
let width = img.width;
|
||||
let height = img.height;
|
||||
if (width > height) {
|
||||
if (width > maxWidth) {
|
||||
height = Math.round((height * maxWidth) / width);
|
||||
width = maxWidth;
|
||||
}
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx?.drawImage(img, 0, 0, width, height);
|
||||
canvas.toBlob(
|
||||
(blob) => {
|
||||
if (!blob) return;
|
||||
const resizedFile = new File([blob], file.name, {
|
||||
type: 'imgage/jpeg',
|
||||
lastModified: Date.now(),
|
||||
});
|
||||
resolve(resizedFile);
|
||||
},
|
||||
'image/jpeg',
|
||||
quality
|
||||
);
|
||||
};
|
||||
} else if (height > maxHeight) {
|
||||
width = Math.round((width * maxHeight) / height);
|
||||
height = maxHeight;
|
||||
}
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx?.drawImage(img, 0, 0, width, height);
|
||||
canvas.toBlob(
|
||||
(blob) => {
|
||||
if (!blob) return;
|
||||
const resizedFile = new File([blob], file.name, {
|
||||
type: 'imgage/jpeg',
|
||||
lastModified: Date.now(),
|
||||
});
|
||||
resolve(resizedFile);
|
||||
},
|
||||
'image/jpeg',
|
||||
quality,
|
||||
);
|
||||
};
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
||||
|
@ -1,14 +1,13 @@
|
||||
'use client'
|
||||
'use client';
|
||||
|
||||
import { useState, useRef } from 'react';
|
||||
import { replaceFile, uploadFile } from '@/lib/hooks';
|
||||
import { toast } from 'sonner';
|
||||
import { useAuth } from '@/components/context/auth';
|
||||
import { resizeImage } from '@/lib/hooks';
|
||||
import type { Result } from '.';
|
||||
|
||||
export type Replace =
|
||||
| { replace: true, path: string }
|
||||
| false;
|
||||
export type Replace = { replace: true; path: string } | false;
|
||||
|
||||
export type uploadToStorageProps = {
|
||||
file: File;
|
||||
@ -33,7 +32,7 @@ export const useFileUpload = () => {
|
||||
resize = false,
|
||||
options = {},
|
||||
replace = false,
|
||||
}: uploadToStorageProps) => {
|
||||
}: uploadToStorageProps): Promise<Result<string>> => {
|
||||
try {
|
||||
if (!isAuthenticated) throw new Error('User is not authenticated');
|
||||
|
||||
@ -48,10 +47,9 @@ export const useFileUpload = () => {
|
||||
},
|
||||
});
|
||||
if (!updateResult.success) {
|
||||
console.error('Error updating file:', updateResult.error);
|
||||
return { success: false, error: updateResult.error };
|
||||
} else {
|
||||
console.log('We used the new update function hopefully it worked!');
|
||||
return { success: true, path: updateResult.data };
|
||||
return { success: true, data: updateResult.data };
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,15 +75,21 @@ export const useFileUpload = () => {
|
||||
throw new Error(uploadResult.error || `Failed to upload to ${bucket}`);
|
||||
}
|
||||
|
||||
return { success: true, path: uploadResult.data };
|
||||
return { success: true, data: uploadResult.data };
|
||||
} catch (error) {
|
||||
console.error(`Error uploading to ${bucket}:`, error);
|
||||
toast.error(
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: `Failed to upload to ${bucket}`,
|
||||
);
|
||||
return { success: false, error };
|
||||
return {
|
||||
success: false,
|
||||
error: `Error: ${
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: `Failed to upload to ${bucket}`
|
||||
}`,
|
||||
};
|
||||
} finally {
|
||||
setIsUploading(false);
|
||||
// Clear the input value so the same file can be selected again
|
||||
|
@ -2,14 +2,13 @@
|
||||
// https://deno.land/manual/getting_started/setup_your_environment
|
||||
// This enables autocomplete, go to definition, etc.
|
||||
|
||||
import { serve } from "https://deno.land/std@0.177.1/http/server.ts"
|
||||
import { serve } from 'https://deno.land/std@0.177.1/http/server.ts';
|
||||
|
||||
serve(async () => {
|
||||
return new Response(
|
||||
`"Hello from Edge Functions!"`,
|
||||
{ headers: { "Content-Type": "application/json" } },
|
||||
)
|
||||
})
|
||||
return new Response(`"Hello from Edge Functions!"`, {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
});
|
||||
|
||||
// To invoke:
|
||||
// curl 'http://localhost:<KONG_HTTP_PORT>/functions/v1/hello' \
|
||||
|
@ -1,78 +1,78 @@
|
||||
import { serve } from 'https://deno.land/std@0.131.0/http/server.ts'
|
||||
import * as jose from 'https://deno.land/x/jose@v4.14.4/index.ts'
|
||||
import { serve } from 'https://deno.land/std@0.131.0/http/server.ts';
|
||||
import * as jose from 'https://deno.land/x/jose@v4.14.4/index.ts';
|
||||
|
||||
console.log('main function started')
|
||||
console.log('main function started');
|
||||
|
||||
const JWT_SECRET = Deno.env.get('JWT_SECRET')
|
||||
const VERIFY_JWT = Deno.env.get('VERIFY_JWT') === 'true'
|
||||
const JWT_SECRET = Deno.env.get('JWT_SECRET');
|
||||
const VERIFY_JWT = Deno.env.get('VERIFY_JWT') === 'true';
|
||||
|
||||
function getAuthToken(req: Request) {
|
||||
const authHeader = req.headers.get('authorization')
|
||||
const authHeader = req.headers.get('authorization');
|
||||
if (!authHeader) {
|
||||
throw new Error('Missing authorization header')
|
||||
throw new Error('Missing authorization header');
|
||||
}
|
||||
const [bearer, token] = authHeader.split(' ')
|
||||
const [bearer, token] = authHeader.split(' ');
|
||||
if (bearer !== 'Bearer') {
|
||||
throw new Error(`Auth header is not 'Bearer {token}'`)
|
||||
throw new Error(`Auth header is not 'Bearer {token}'`);
|
||||
}
|
||||
return token
|
||||
return token;
|
||||
}
|
||||
|
||||
async function verifyJWT(jwt: string): Promise<boolean> {
|
||||
const encoder = new TextEncoder()
|
||||
const secretKey = encoder.encode(JWT_SECRET)
|
||||
const encoder = new TextEncoder();
|
||||
const secretKey = encoder.encode(JWT_SECRET);
|
||||
try {
|
||||
await jose.jwtVerify(jwt, secretKey)
|
||||
await jose.jwtVerify(jwt, secretKey);
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
return false
|
||||
console.error(err);
|
||||
return false;
|
||||
}
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
serve(async (req: Request) => {
|
||||
if (req.method !== 'OPTIONS' && VERIFY_JWT) {
|
||||
try {
|
||||
const token = getAuthToken(req)
|
||||
const isValidJWT = await verifyJWT(token)
|
||||
const token = getAuthToken(req);
|
||||
const isValidJWT = await verifyJWT(token);
|
||||
|
||||
if (!isValidJWT) {
|
||||
return new Response(JSON.stringify({ msg: 'Invalid JWT' }), {
|
||||
status: 401,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
console.error(e);
|
||||
return new Response(JSON.stringify({ msg: e.toString() }), {
|
||||
status: 401,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const url = new URL(req.url)
|
||||
const { pathname } = url
|
||||
const path_parts = pathname.split('/')
|
||||
const service_name = path_parts[1]
|
||||
const url = new URL(req.url);
|
||||
const { pathname } = url;
|
||||
const path_parts = pathname.split('/');
|
||||
const service_name = path_parts[1];
|
||||
|
||||
if (!service_name || service_name === '') {
|
||||
const error = { msg: 'missing function name in request' }
|
||||
const error = { msg: 'missing function name in request' };
|
||||
return new Response(JSON.stringify(error), {
|
||||
status: 400,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
const servicePath = `/home/deno/functions/${service_name}`
|
||||
console.error(`serving the request with ${servicePath}`)
|
||||
const servicePath = `/home/deno/functions/${service_name}`;
|
||||
console.error(`serving the request with ${servicePath}`);
|
||||
|
||||
const memoryLimitMb = 150
|
||||
const workerTimeoutMs = 1 * 60 * 1000
|
||||
const noModuleCache = false
|
||||
const importMapPath = null
|
||||
const envVarsObj = Deno.env.toObject()
|
||||
const envVars = Object.keys(envVarsObj).map((k) => [k, envVarsObj[k]])
|
||||
const memoryLimitMb = 150;
|
||||
const workerTimeoutMs = 1 * 60 * 1000;
|
||||
const noModuleCache = false;
|
||||
const importMapPath = null;
|
||||
const envVarsObj = Deno.env.toObject();
|
||||
const envVars = Object.keys(envVarsObj).map((k) => [k, envVarsObj[k]]);
|
||||
|
||||
try {
|
||||
const worker = await EdgeRuntime.userWorkers.create({
|
||||
@ -82,13 +82,13 @@ serve(async (req: Request) => {
|
||||
noModuleCache,
|
||||
importMapPath,
|
||||
envVars,
|
||||
})
|
||||
return await worker.fetch(req)
|
||||
});
|
||||
return await worker.fetch(req);
|
||||
} catch (e) {
|
||||
const error = { msg: e.toString() }
|
||||
const error = { msg: e.toString() };
|
||||
return new Response(JSON.stringify(error), {
|
||||
status: 500,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@ -2,9 +2,9 @@ import { createServerClient } from '@supabase/ssr';
|
||||
import { type NextRequest, NextResponse } from 'next/server';
|
||||
import type { Database } from '@/utils/supabase/types';
|
||||
|
||||
export const updateSession = async (request: NextRequest) => {
|
||||
// This `try/catch` block is only here for the interactive tutorial.
|
||||
// Feel free to remove once you have Supabase connected.
|
||||
export const updateSession = async (
|
||||
request: NextRequest,
|
||||
): Promise<NextResponse> => {
|
||||
try {
|
||||
// Create an unmodified response
|
||||
let response = NextResponse.next({
|
||||
@ -45,15 +45,8 @@ export const updateSession = async (request: NextRequest) => {
|
||||
return NextResponse.redirect(new URL('/sign-in', request.url));
|
||||
}
|
||||
|
||||
//if (request.nextUrl.pathname === '/' && !user.error) {
|
||||
//return NextResponse.redirect(new URL('/protected', request.url));
|
||||
//}
|
||||
|
||||
return response;
|
||||
} catch (e) {
|
||||
// If you are here, a Supabase client could not be created!
|
||||
// This is likely because you have not set up environment variables.
|
||||
// Check out http://localhost:3000 for Next Steps.
|
||||
return NextResponse.next({
|
||||
request: {
|
||||
headers: request.headers,
|
||||
|
@ -1,4 +1,4 @@
|
||||
'use server'
|
||||
'use server';
|
||||
|
||||
import 'server-only';
|
||||
import { createServerClient as CreateServerClient } from '@supabase/ssr';
|
||||
|
@ -1,16 +0,0 @@
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
/**
|
||||
* Redirects to a specified path with an encoded message as a query parameter.
|
||||
* @param {('error' | 'success')} type - The type of message, either 'error' or 'success'.
|
||||
* @param {string} path - The path to redirect to.
|
||||
* @param {string} message - The message to be encoded and added as a query parameter.
|
||||
* @returns {never} This function doesn't return as it triggers a redirect.
|
||||
*/
|
||||
export function encodedRedirect(
|
||||
type: 'error' | 'success',
|
||||
path: string,
|
||||
message: string,
|
||||
) {
|
||||
return redirect(`${path}?${type}=${encodeURIComponent(message)}`);
|
||||
}
|
Reference in New Issue
Block a user