The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: made the join page public
Jonathan Summers-Muir909a758f8636
diff --git a/studio/package-lock.json b/studio/package-lock.jsonindex 93075f14786..5a72584b7e0 100644--- a/studio/package-lock.json+++ b/studio/package-lock.json@@ -47,7 +47,6 @@"path-to-regexp": "^6.2.0","prism-react-renderer": "^1.2.1","react": "^17.0.2",- "react-auth-code-input": "^3.2.0","react-beautiful-dnd": "^13.1.0","react-contexify": "^5.0.0","react-csv": "^2.0.3",@@ -71,6 +70,7 @@"swr": "^1.2.1","uniforms-bootstrap4": "^3.6.2","uniforms-bridge-json-schema": "^3.6.2",+ "uuid": "^8.3.2","zxcvbn": "^4.4.2"},"devDependencies": {@@ -101,6 +101,7 @@"@types/react-window-infinite-loader": "^1.0.5","@types/semver": "^7.3.9","@types/sqlstring": "^2.3.0",+ "@types/uuid": "^8.3.4","@types/zxcvbn": "^4.4.1","autoprefixer": "^10.4.2","babel-loader": "^8.2.3",@@ -9049,6 +9050,12 @@"integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==","dev": true},+ "node_modules/@types/uuid": {+ "version": "8.3.4",+ "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz",+ "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==",+ "dev": true+ },"node_modules/@types/webpack": {"version": "4.41.32","resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.32.tgz",@@ -9473,6 +9480,15 @@"node": ">=4"}},+ "node_modules/analytics-node/node_modules/uuid": {+ "version": "3.4.0",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",+ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",+ "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",+ "bin": {+ "uuid": "bin/uuid"+ }+ },"node_modules/anser": {"version": "1.4.9","resolved": "https://registry.npmjs.org/anser/-/anser-1.4.9.tgz",@@ -22876,17 +22892,6 @@"node": ">=0.10.0"}},- "node_modules/react-auth-code-input": {- "version": "3.2.0",- "resolved": "https://registry.npmjs.org/react-auth-code-input/-/react-auth-code-input-3.2.0.tgz",- "integrity": "sha512-ctTudLbvX//4OiX3nRMAWMD3h84ROQzY+lzO09SFJ54L+w8lOl0yV6hFTyPD9drT/eVgfZScpCGlN+R5b3x/nw==",- "engines": {- "node": ">=10"- },- "peerDependencies": {- "react": ">=16.0.0"- }- },"node_modules/react-beautiful-dnd": {"version": "13.1.0","resolved": "https://registry.npmjs.org/react-beautiful-dnd/-/react-beautiful-dnd-13.1.0.tgz",@@ -27456,12 +27461,11 @@}},"node_modules/uuid": {- "version": "3.4.0",- "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",- "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",- "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",+ "version": "8.3.2",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",+ "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==","bin": {- "uuid": "bin/uuid"+ "uuid": "dist/bin/uuid"}},"node_modules/uuid-browser": {@@ -28155,6 +28159,16 @@"node": ">= 6"}},+ "node_modules/webpack-log/node_modules/uuid": {+ "version": "3.4.0",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",+ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",+ "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",+ "dev": true,+ "bin": {+ "uuid": "bin/uuid"+ }+ },"node_modules/webpack-sources": {"version": "1.4.3","resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz",@@ -35781,6 +35795,12 @@"integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==","dev": true},+ "@types/uuid": {+ "version": "8.3.4",+ "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz",+ "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==",+ "dev": true+ },"@types/webpack": {"version": "4.41.32","resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.32.tgz",@@ -36163,6 +36183,13 @@"ms": "^2.0.0","remove-trailing-slash": "^0.1.0","uuid": "^3.2.1"+ },+ "dependencies": {+ "uuid": {+ "version": "3.4.0",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",+ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="+ }}},"anser": {@@ -46537,12 +46564,6 @@"object-assign": "^4.1.1"}},- "react-auth-code-input": {- "version": "3.2.0",- "resolved": "https://registry.npmjs.org/react-auth-code-input/-/react-auth-code-input-3.2.0.tgz",- "integrity": "sha512-ctTudLbvX//4OiX3nRMAWMD3h84ROQzY+lzO09SFJ54L+w8lOl0yV6hFTyPD9drT/eVgfZScpCGlN+R5b3x/nw==",- "requires": {}- },"react-beautiful-dnd": {"version": "13.1.0","resolved": "https://registry.npmjs.org/react-beautiful-dnd/-/react-beautiful-dnd-13.1.0.tgz",@@ -49999,9 +50020,9 @@"dev": true},"uuid": {- "version": "3.4.0",- "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",- "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="+ "version": "8.3.2",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",+ "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="},"uuid-browser": {"version": "3.1.0",@@ -50863,6 +50884,14 @@"requires": {"ansi-colors": "^3.0.0","uuid": "^3.3.2"+ },+ "dependencies": {+ "uuid": {+ "version": "3.4.0",+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",+ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",+ "dev": true+ }}},"webpack-sources": {diff --git a/studio/pages/index.tsx b/studio/pages/index.tsxindex 45826dc1282..d2b39ce06fe 100644--- a/studio/pages/index.tsx+++ b/studio/pages/index.tsx@@ -146,6 +146,8 @@ const IndexLayout = withAuth(router.push(`/vercel/integrate?${params.toString()}`)} else if (router.query?.next?.includes('new-project')) {router.push('/new/project')+ } else if (router.query?.next?.includes('join')) {+ router.push(`/${router.query.next}`)} else if (typeof router.query?.next === 'string' &&router.query?.next?.startsWith('project/_/')diff --git a/studio/pages/join/index.tsx b/studio/pages/join/index.tsxnew file mode 100644index 00000000000..3f41a06c6ff--- /dev/null+++ b/studio/pages/join/index.tsx@@ -0,0 +1,180 @@+import React from 'react'+import { useStore, withAuth } from 'hooks'+import { Button, IconAlertCircle, Typography } from '@supabase/ui'+import { useState } from 'react'+import { useRouter } from 'next/router'+import Link from 'next/link'+import { API_URL } from 'lib/constants'+import { get, post, delete_ } from 'lib/common/fetch'+import { useEffect } from 'react'++interface TokenInfo {+ organization_name: string | undefined+ token_does_not_exist: boolean+ email_match: boolean+ authorized_user: boolean+ expired_token: boolean+ invite_id: number+}++const User = () => {+ const router = useRouter()+ const { slug, token } = router.query+ const { ui } = useStore()+ const [isSubmitting, setIsSubmitting] = useState(false)+ const [tokenValidationInfo, setTokenValidationInfo] = useState<TokenInfo>()+ const [tokenInfoLoaded, setTokenInfoLoaded] = useState(false)+ const {+ token_does_not_exist,+ email_match,+ authorized_user,+ expired_token,+ organization_name,+ invite_id,+ } = tokenValidationInfo || {}++ console.log(slug, token)+ console.log('tokenValidationInfo', tokenValidationInfo)+ console.log('tokenInfoLoaded', tokenInfoLoaded)++ useEffect(() => {+ let cancel = false++ async function fetchTokenInfo() {+ const response = await get(`${API_URL}/organizations/${slug}/members/join?token=${token}`, {})+ if (!cancel) {+ setTokenValidationInfo(response)+ setTokenInfoLoaded(true)+ }+ }++ if (router.query.token) {+ console.log('i have a tokens')+ fetchTokenInfo()+ }++ return () => {+ cancel = true+ }+ }, [])++ async function handleJoinOrganization() {+ setIsSubmitting(true)+ const response = await post(`${API_URL}/organizations/${slug}/members/join?token=${token}`, {})+ if (response.error) {+ ui.setNotification({+ category: 'error',+ message: `Failed to join organization: ${response.error.message}`,+ })+ setIsSubmitting(false)+ } else {+ setIsSubmitting(false)+ // app.organizations.load()+ router.push('/')+ }+ }++ async function handleDeclineJoinOrganization() {+ setIsSubmitting(true)+ const response = await delete_(+ `${API_URL}/organizations/${slug}/members/invite?invited_id=${invite_id}`,+ {}+ )+ if (response.error) {+ ui.setNotification({+ category: 'error',+ message: `Failed to decline invitation: ${response.error.message}`,+ })+ setIsSubmitting(false)+ } else {+ setIsSubmitting(false)+ router.push('/')+ }+ }++ return (+ <div className="bg-secondary flex h-full min-h-screen w-full flex-col place-items-center items-center justify-center px-3">+ <Link+ passHref+ href={`/?next=${encodeURIComponent(+ `/join/?token=${router.query.token}&slug=${router.query.slug}`+ )}`}+ >+ <Button as="a">Sign in / Sign up</Button>+ </Link>++ <div className="mx-auto mt-16 max-w-md space-y-6 rounded-md border-2 p-12 ">+ <div className="space-y-4">+ <Link href="/">+ <a className="flex items-center gap-4">+ <img+ src="/img/supabase-logo.svg"+ alt="Supabase"+ className="block h-[30px] cursor-pointer rounded"+ />+ <Typography.Title level={3} className="mb-0">+ Supabase+ </Typography.Title>+ </a>+ </Link>++ <h2 className="text-xl">+ Join {organization_name && email_match ? organization_name : 'a new organization'}+ </h2>++ {!token_does_not_exist ? (+ <p className="text-md">+ You have been invited to join{' '}+ {organization_name && email_match+ ? `${organization_name}'s organization`+ : 'a new organization'}{' '}+ at Supabase.+ </p>+ ) : (+ <div className="w-96" />+ )}+ </div>++ {authorized_user && !expired_token && email_match && tokenInfoLoaded && (+ <div className="flex items-center gap-2">+ <Button+ onClick={handleJoinOrganization}+ htmlType="submit"+ loading={isSubmitting}+ size="small"+ >+ Join this organization+ </Button>++ <Button+ onClick={handleDeclineJoinOrganization}+ htmlType="submit"+ size="small"+ type="text"+ >+ Decline+ </Button>+ </div>+ )}++ {tokenInfoLoaded && (+ <div className="mt-4 flex gap-4 border-t pt-4 text-sm">+ {token_does_not_exist ||+ !email_match ||+ (expired_token && <IconAlertCircle size={24} strokeWidth={2} />)}++ {token_does_not_exist+ ? 'The invite token is invalid. Try copying and pasting the link from the invite email, or ask the organization owner to invite you again.'+ : !email_match+ ? 'The email address does not match. Are you signed in with right GitHub account?'+ : expired_token+ ? 'The invite token has expired. Please request a new one from the organization owner.'+ : ''}+ </div>+ )}+ </div>+ </div>+ )+}++export default User