MingruiZhang commited on
Commit
3c3ac54
1 Parent(s): 9882676

landing.ai

Browse files
Files changed (4) hide show
  1. app/unauthorized/page.tsx +7 -0
  2. auth.ts +9 -2
  3. package.json +69 -69
  4. yarn.lock +25 -19
app/unauthorized/page.tsx ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ export default async function Unauthorized() {
2
+ return (
3
+ <div className="flex flex-col h-[calc(100vh-theme(spacing.16))] items-center justify-center py-10 space-y-2">
4
+ You are not authorized to view this page. Please sign in to continue.
5
+ </div>
6
+ );
7
+ }
auth.ts CHANGED
@@ -23,6 +23,13 @@ export const {
23
  }),
24
  ],
25
  callbacks: {
 
 
 
 
 
 
 
26
  jwt({ token, profile }) {
27
  if (profile) {
28
  token.id = profile.id || profile.sub;
@@ -36,8 +43,8 @@ export const {
36
  }
37
  return session;
38
  },
39
- authorized({ auth }) {
40
- return !!auth?.user; // this ensures there is a logged in user for -every- request
41
  },
42
  },
43
  pages: {
 
23
  }),
24
  ],
25
  callbacks: {
26
+ signIn({ profile }) {
27
+ if (profile?.email?.endsWith('@landing.ai')) {
28
+ return !!profile;
29
+ } else {
30
+ return '/unauthorized';
31
+ }
32
+ },
33
  jwt({ token, profile }) {
34
  if (profile) {
35
  token.id = profile.id || profile.sub;
 
43
  }
44
  return session;
45
  },
46
+ authorized({ request, auth }) {
47
+ return !!auth?.user || request.nextUrl.pathname === '/unauthorized'; // this ensures there is a logged in user for -every- request
48
  },
49
  },
50
  pages: {
package.json CHANGED
@@ -1,71 +1,71 @@
1
  {
2
- "private": true,
3
- "scripts": {
4
- "dev": "next dev --turbo",
5
- "build": "next build",
6
- "start": "next start",
7
- "lint": "next lint",
8
- "lint:fix": "next lint --fix",
9
- "preview": "next build && next start",
10
- "type-check": "tsc --noEmit",
11
- "format:write": "prettier --write \"{app,lib,components}/**/*.{ts,tsx,mdx}\" --cache",
12
- "format:check": "prettier --check \"{app,lib,components}**/*.{ts,tsx,mdx}\" --cache"
13
- },
14
- "dependencies": {
15
- "@radix-ui/react-alert-dialog": "^1.0.5",
16
- "@radix-ui/react-dialog": "^1.0.5",
17
- "@radix-ui/react-dropdown-menu": "^2.0.6",
18
- "@radix-ui/react-label": "^2.0.2",
19
- "@radix-ui/react-select": "^2.0.0",
20
- "@radix-ui/react-separator": "^1.0.3",
21
- "@radix-ui/react-slot": "^1.0.2",
22
- "@radix-ui/react-switch": "^1.0.3",
23
- "@radix-ui/react-tooltip": "^1.0.7",
24
- "@vercel/analytics": "^1.1.2",
25
- "@vercel/kv": "^1.0.1",
26
- "@vercel/og": "^0.6.2",
27
- "ai": "^2.2.31",
28
- "class-variance-authority": "^0.7.0",
29
- "clsx": "^2.1.0",
30
- "focus-trap-react": "^10.2.3",
31
- "framer-motion": "^10.18.0",
32
- "geist": "^1.2.1",
33
- "immer": "^10.0.3",
34
- "jotai": "^2.7.0",
35
- "nanoid": "^5.0.4",
36
- "next": "14.1.0",
37
- "next-auth": "5.0.0-beta.4",
38
- "next-themes": "^0.2.1",
39
- "openai": "^4.24.7",
40
- "react": "^18.2.0",
41
- "react-dom": "^18.2.0",
42
- "react-dropzone": "^14.2.3",
43
- "react-hot-toast": "^2.4.1",
44
- "react-intersection-observer": "^9.5.3",
45
- "react-markdown": "^8.0.7",
46
- "react-syntax-highlighter": "^15.5.0",
47
- "react-textarea-autosize": "^8.5.3",
48
- "remark-gfm": "^3.0.1",
49
- "remark-math": "^5.1.1"
50
- },
51
- "devDependencies": {
52
- "@tailwindcss/typography": "^0.5.10",
53
- "@types/node": "^20.11.5",
54
- "@types/react": "^18.2.48",
55
- "@types/react-dom": "^18.2.18",
56
- "@types/react-syntax-highlighter": "^15.5.11",
57
- "@typescript-eslint/parser": "^6.19.0",
58
- "autoprefixer": "^10.4.17",
59
- "eslint": "^8.56.0",
60
- "eslint-config-next": "14.1.0",
61
- "eslint-config-prettier": "^9.1.0",
62
- "eslint-plugin-tailwindcss": "^3.14.0",
63
- "postcss": "^8.4.33",
64
- "prettier": "^3.2.4",
65
- "tailwind-merge": "^2.2.0",
66
- "tailwindcss": "^3.4.1",
67
- "tailwindcss-animate": "^1.0.7",
68
- "typescript": "^5.3.3"
69
- },
70
- "packageManager": "pnpm@8.6.3"
71
  }
 
1
  {
2
+ "private": true,
3
+ "scripts": {
4
+ "dev": "next dev --turbo",
5
+ "build": "next build",
6
+ "start": "next start",
7
+ "lint": "next lint",
8
+ "lint:fix": "next lint --fix",
9
+ "preview": "next build && next start",
10
+ "type-check": "tsc --noEmit",
11
+ "format:write": "prettier --write \"{app,lib,components}/**/*.{ts,tsx,mdx}\" --cache",
12
+ "format:check": "prettier --check \"{app,lib,components}**/*.{ts,tsx,mdx}\" --cache"
13
+ },
14
+ "dependencies": {
15
+ "@radix-ui/react-alert-dialog": "^1.0.5",
16
+ "@radix-ui/react-dialog": "^1.0.5",
17
+ "@radix-ui/react-dropdown-menu": "^2.0.6",
18
+ "@radix-ui/react-label": "^2.0.2",
19
+ "@radix-ui/react-select": "^2.0.0",
20
+ "@radix-ui/react-separator": "^1.0.3",
21
+ "@radix-ui/react-slot": "^1.0.2",
22
+ "@radix-ui/react-switch": "^1.0.3",
23
+ "@radix-ui/react-tooltip": "^1.0.7",
24
+ "@vercel/analytics": "^1.1.2",
25
+ "@vercel/kv": "^1.0.1",
26
+ "@vercel/og": "^0.6.2",
27
+ "ai": "^2.2.31",
28
+ "class-variance-authority": "^0.7.0",
29
+ "clsx": "^2.1.0",
30
+ "focus-trap-react": "^10.2.3",
31
+ "framer-motion": "^10.18.0",
32
+ "geist": "^1.2.1",
33
+ "immer": "^10.0.3",
34
+ "jotai": "^2.7.0",
35
+ "nanoid": "^5.0.4",
36
+ "next": "14.1.0",
37
+ "next-auth": "5.0.0-beta.16",
38
+ "next-themes": "^0.2.1",
39
+ "openai": "^4.24.7",
40
+ "react": "^18.2.0",
41
+ "react-dom": "^18.2.0",
42
+ "react-dropzone": "^14.2.3",
43
+ "react-hot-toast": "^2.4.1",
44
+ "react-intersection-observer": "^9.5.3",
45
+ "react-markdown": "^8.0.7",
46
+ "react-syntax-highlighter": "^15.5.0",
47
+ "react-textarea-autosize": "^8.5.3",
48
+ "remark-gfm": "^3.0.1",
49
+ "remark-math": "^5.1.1"
50
+ },
51
+ "devDependencies": {
52
+ "@tailwindcss/typography": "^0.5.10",
53
+ "@types/node": "^20.11.5",
54
+ "@types/react": "^18.2.48",
55
+ "@types/react-dom": "^18.2.18",
56
+ "@types/react-syntax-highlighter": "^15.5.11",
57
+ "@typescript-eslint/parser": "^6.19.0",
58
+ "autoprefixer": "^10.4.17",
59
+ "eslint": "^8.56.0",
60
+ "eslint-config-next": "14.1.0",
61
+ "eslint-config-prettier": "^9.1.0",
62
+ "eslint-plugin-tailwindcss": "^3.14.0",
63
+ "postcss": "^8.4.33",
64
+ "prettier": "^3.2.4",
65
+ "tailwind-merge": "^2.2.0",
66
+ "tailwindcss": "^3.4.1",
67
+ "tailwindcss-animate": "^1.0.7",
68
+ "typescript": "^5.3.3"
69
+ },
70
+ "packageManager": "pnpm@8.6.3"
71
  }
yarn.lock CHANGED
@@ -12,15 +12,16 @@
12
  resolved "https://registry.yarnpkg.com/@alloc/quick-lru/-/quick-lru-5.2.0.tgz#7bf68b20c0a350f936915fcae06f58e32007ce30"
13
  integrity sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==
14
 
15
- "@auth/core@0.18.4":
16
- version "0.18.4"
17
- resolved "https://registry.yarnpkg.com/@auth/core/-/core-0.18.4.tgz#5c91f7835dc24329d5486a2939d766608a7aacb8"
18
- integrity sha512-GsNhsP1xE/3FoNS3dVkPjqRljLNJ4iyL2OLv3klQGNvw3bMpROFcK4lqhx7+pPHiamnVaYt2vg1xbB+lsNaevg==
19
  dependencies:
20
  "@panva/hkdf" "^1.1.1"
 
21
  cookie "0.6.0"
22
- jose "^5.1.0"
23
- oauth4webapi "^2.3.0"
24
  preact "10.11.3"
25
  preact-render-to-string "5.2.3"
26
 
@@ -663,6 +664,11 @@
663
  lodash.merge "^4.6.2"
664
  postcss-selector-parser "6.0.10"
665
 
 
 
 
 
 
666
  "@types/debug@^4.0.0":
667
  version "4.1.12"
668
  resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.12.tgz#a155f21690871953410df4b6b6f53187f0500917"
@@ -2562,10 +2568,10 @@ jiti@^1.19.1:
2562
  resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.0.tgz#7c97f8fe045724e136a397f7340475244156105d"
2563
  integrity sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==
2564
 
2565
- jose@^5.1.0:
2566
- version "5.2.2"
2567
- resolved "https://registry.yarnpkg.com/jose/-/jose-5.2.2.tgz#b91170e9ba6dbe609b0c0a86568f9a1fbe4335c0"
2568
- integrity sha512-/WByRr4jDcsKlvMd1dRJnPfS1GVO3WuKyaurJ/vvXcOaUQO8rnNObCQMlv/5uCceVQIq5Q4WLF44ohsdiTohdg==
2569
 
2570
  jotai@^2.7.0:
2571
  version "2.7.0"
@@ -3272,12 +3278,12 @@ natural-compare@^1.4.0:
3272
  resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
3273
  integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==
3274
 
3275
- next-auth@5.0.0-beta.4:
3276
- version "5.0.0-beta.4"
3277
- resolved "https://registry.yarnpkg.com/next-auth/-/next-auth-5.0.0-beta.4.tgz#3be1ca3a89626e993e04bfc5129a8f8e0afb161b"
3278
- integrity sha512-vgocjvwPA8gxd/zrIP/vr9lJ/HeNe+C56lPP1D3sdyenHt8KncQV6ro7q0xCsDp1fcOKx7WAWVZH5o8aMxDzgw==
3279
  dependencies:
3280
- "@auth/core" "0.18.4"
3281
 
3282
  next-themes@^0.2.1:
3283
  version "0.2.1"
@@ -3334,10 +3340,10 @@ normalize-range@^0.1.2:
3334
  resolved "https://registry.yarnpkg.com/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942"
3335
  integrity sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==
3336
 
3337
- oauth4webapi@^2.3.0:
3338
- version "2.10.3"
3339
- resolved "https://registry.yarnpkg.com/oauth4webapi/-/oauth4webapi-2.10.3.tgz#8e6d5a8a984a297dd80276a6c52634359319d034"
3340
- integrity sha512-9FkXEXfzVKzH63GUOZz1zMr3wBaICSzk6DLXx+CGdrQ10ItNk2ePWzYYc1fdmKq1ayGFb2aX97sRCoZ2s0mkDw==
3341
 
3342
  object-assign@^4.0.1, object-assign@^4.1.1:
3343
  version "4.1.1"
 
12
  resolved "https://registry.yarnpkg.com/@alloc/quick-lru/-/quick-lru-5.2.0.tgz#7bf68b20c0a350f936915fcae06f58e32007ce30"
13
  integrity sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==
14
 
15
+ "@auth/core@0.28.1":
16
+ version "0.28.1"
17
+ resolved "https://registry.yarnpkg.com/@auth/core/-/core-0.28.1.tgz#a60f509424089cf2041efb6d3ff42e2c16791350"
18
+ integrity sha512-gvp74mypYZADpTlfGRp6HE0G3pIHWvtJpy+KZ+8FvY0cmlIpHog+jdMOdd29dQtLtN25kF2YbfHsesCFuGUQbg==
19
  dependencies:
20
  "@panva/hkdf" "^1.1.1"
21
+ "@types/cookie" "0.6.0"
22
  cookie "0.6.0"
23
+ jose "^5.1.3"
24
+ oauth4webapi "^2.4.0"
25
  preact "10.11.3"
26
  preact-render-to-string "5.2.3"
27
 
 
664
  lodash.merge "^4.6.2"
665
  postcss-selector-parser "6.0.10"
666
 
667
+ "@types/cookie@0.6.0":
668
+ version "0.6.0"
669
+ resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.6.0.tgz#eac397f28bf1d6ae0ae081363eca2f425bedf0d5"
670
+ integrity sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==
671
+
672
  "@types/debug@^4.0.0":
673
  version "4.1.12"
674
  resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.12.tgz#a155f21690871953410df4b6b6f53187f0500917"
 
2568
  resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.0.tgz#7c97f8fe045724e136a397f7340475244156105d"
2569
  integrity sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==
2570
 
2571
+ jose@^5.1.3:
2572
+ version "5.2.4"
2573
+ resolved "https://registry.yarnpkg.com/jose/-/jose-5.2.4.tgz#c0d296caeeed0b8444a8b8c3b68403d61aa4ed72"
2574
+ integrity sha512-6ScbIk2WWCeXkmzF6bRPmEuaqy1m8SbsRFMa/FLrSCkGIhj8OLVG/IH+XHVmNMx/KUo8cVWEE6oKR4dJ+S0Rkg==
2575
 
2576
  jotai@^2.7.0:
2577
  version "2.7.0"
 
3278
  resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
3279
  integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==
3280
 
3281
+ next-auth@5.0.0-beta.16:
3282
+ version "5.0.0-beta.16"
3283
+ resolved "https://registry.yarnpkg.com/next-auth/-/next-auth-5.0.0-beta.16.tgz#cf02c9e5bbf4b91463943c0391604fcb5f46b22d"
3284
+ integrity sha512-dX2snB+ezN23tFzSes3n3uosT9iBf0eILPYWH/R2fd9n3ZzdMQlRzq7JIOPeS1aLc84IuRlyuyXyx9XmmZB6og==
3285
  dependencies:
3286
+ "@auth/core" "0.28.1"
3287
 
3288
  next-themes@^0.2.1:
3289
  version "0.2.1"
 
3340
  resolved "https://registry.yarnpkg.com/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942"
3341
  integrity sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==
3342
 
3343
+ oauth4webapi@^2.4.0:
3344
+ version "2.10.4"
3345
+ resolved "https://registry.yarnpkg.com/oauth4webapi/-/oauth4webapi-2.10.4.tgz#4194b784e0ff995edd64bd90177fd7f25b7fbb17"
3346
+ integrity sha512-DSoj8QoChzOCQlJkRmYxAJCIpnXFW32R0Uq7avyghIeB6iJq0XAblOD7pcq3mx4WEBDwMuKr0Y1qveCBleG2Xw==
3347
 
3348
  object-assign@^4.0.1, object-assign@^4.1.1:
3349
  version "4.1.1"