This commit is contained in:
avallete committed 2024-12-09 18:16:52 +01:00
1 parent 735f4b7a25
commit b3fa37037c
4 files changed
+128 -71

No files matched your search

@@ -9,6 +9,8 @@
"version": "0.2.0",
"license": "MIT",
"dependencies": {
"@supabase/auth-ui-react": "^0.4.7",
"@supabase/auth-ui-shared": "^0.1.8",
"@supabase/supabase-js": "^2.47.3",
"jwt-decode": "^4.0.0",
"next": "latest",
@@ -441,6 +443,12 @@
"node": ">= 8"
}
},
"node_modules/@stitches/core": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/@stitches/core/-/core-1.2.8.tgz",
"integrity": "sha512-Gfkvwk9o9kE9r9XNBmJRfV8zONvXThnm1tcuojL04Uy5uRyqg93DC83lDebl0rocZCfKSjUv+fWYtMQmEDJldg==",
"license": "MIT"
},
"node_modules/@supabase/auth-js": {
"version": "2.66.1",
"resolved": "https://registry.npmjs.org/@supabase/auth-js/-/auth-js-2.66.1.tgz",
@@ -450,6 +458,30 @@
"@supabase/node-fetch": "^2.6.14"
}
},
"node_modules/@supabase/auth-ui-react": {
"version": "0.4.7",
"resolved": "https://registry.npmjs.org/@supabase/auth-ui-react/-/auth-ui-react-0.4.7.tgz",
"integrity": "sha512-Lp4FQGFh7BMX1Y/BFaUKidbryL7eskj1fl6Lby7BeHrTctbdvDbCMjVKS8wZ2rxuI8FtPS2iU900fSb70FHknQ==",
"dependencies": {
"@stitches/core": "^1.2.8",
"@supabase/auth-ui-shared": "0.1.8",
"prop-types": "^15.7.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"peerDependencies": {
"@supabase/supabase-js": "^2.21.0"
}
},
"node_modules/@supabase/auth-ui-shared": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@supabase/auth-ui-shared/-/auth-ui-shared-0.1.8.tgz",
"integrity": "sha512-ouQ0DjKcEFg+0gZigFIEgu01V3e6riGZPzgVD0MJsCBNsMsiDT74+GgCEIElMUpTGkwSja3xLwdFRFgMNFKcjg==",
"license": "MIT",
"peerDependencies": {
"@supabase/supabase-js": "^2.21.0"
}
},
"node_modules/@supabase/functions-js": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/@supabase/functions-js/-/functions-js-2.4.3.tgz",
@@ -1355,7 +1387,6 @@
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
@@ -1576,6 +1607,17 @@
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==",
"dev": true
},
"node_modules/prop-types": {
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
"license": "MIT",
"dependencies": {
"loose-envify": "^1.4.0",
"object-assign": "^4.1.1",
"react-is": "^16.13.1"
}
},
"node_modules/queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
@@ -1619,6 +1661,12 @@
"react": "^18.2.0"
}
},
"node_modules/react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
"license": "MIT"
},
"node_modules/read-cache": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
@@ -2273,6 +2321,11 @@
"fastq": "^1.6.0"
}
},
"@stitches/core": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/@stitches/core/-/core-1.2.8.tgz",
"integrity": "sha512-Gfkvwk9o9kE9r9XNBmJRfV8zONvXThnm1tcuojL04Uy5uRyqg93DC83lDebl0rocZCfKSjUv+fWYtMQmEDJldg=="
},
"@supabase/auth-js": {
"version": "2.66.1",
"resolved": "https://registry.npmjs.org/@supabase/auth-js/-/auth-js-2.66.1.tgz",
@@ -2281,6 +2334,24 @@
"@supabase/node-fetch": "^2.6.14"
}
},
"@supabase/auth-ui-react": {
"version": "0.4.7",
"resolved": "https://registry.npmjs.org/@supabase/auth-ui-react/-/auth-ui-react-0.4.7.tgz",
"integrity": "sha512-Lp4FQGFh7BMX1Y/BFaUKidbryL7eskj1fl6Lby7BeHrTctbdvDbCMjVKS8wZ2rxuI8FtPS2iU900fSb70FHknQ==",
"requires": {
"@stitches/core": "^1.2.8",
"@supabase/auth-ui-shared": "0.1.8",
"prop-types": "^15.7.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
},
"@supabase/auth-ui-shared": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@supabase/auth-ui-shared/-/auth-ui-shared-0.1.8.tgz",
"integrity": "sha512-ouQ0DjKcEFg+0gZigFIEgu01V3e6riGZPzgVD0MJsCBNsMsiDT74+GgCEIElMUpTGkwSja3xLwdFRFgMNFKcjg==",
"requires": {}
},
"@supabase/functions-js": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/@supabase/functions-js/-/functions-js-2.4.3.tgz",
@@ -2903,8 +2974,7 @@
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"dev": true
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="
},
"object-hash": {
"version": "3.0.0",
@@ -3034,6 +3104,16 @@
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==",
"dev": true
},
"prop-types": {
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
"requires": {
"loose-envify": "^1.4.0",
"object-assign": "^4.1.1",
"react-is": "^16.13.1"
}
},
"queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
@@ -3057,6 +3137,11 @@
"scheduler": "^0.23.0"
}
},
"react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
},
"read-cache": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
@@ -3,12 +3,14 @@
"version": "0.2.0",
"license": "MIT",
"scripts": {
"dev": "next dev",
"dev": "next dev -p 3456",
"export": "next export",
"build": "next build",
"start": "next start"
},
"dependencies": {
"@supabase/auth-ui-react": "^0.4.7",
"@supabase/auth-ui-shared": "^0.1.8",
"@supabase/supabase-js": "^2.47.3",
"jwt-decode": "^4.0.0",
"next": "latest",
@@ -1,79 +1,42 @@
import { useState } from 'react'
import { useState, useEffect } from 'react'
import { supabase } from 'lib/Store'
import { Auth } from '@supabase/auth-ui-react'
import { ThemeSupa } from '@supabase/auth-ui-shared'
const Home = () => {
const [username, setUsername] = useState('')
const [password, setPassword] = useState('')
const [session, setSession] = useState(null)
const handleLogin = async (type, username, password) => {
try {
const { error, data: { user } } =
type === 'LOGIN'
? await supabase.auth.signInWithPassword({ email: username, password })
: await supabase.auth.signUp({ email: username, password })
// If the user doesn't exist here and an error hasn't been raised yet,
// that must mean that a confirmation email has been sent.
// NOTE: Confirming your email address is required by default.
if (error) {
alert('Error with auth: ' + error.message)
} else if (!user) alert('Signup successful, confirmation mail should be sent soon!')
} catch (error) {
console.log('error', error)
alert(error.error_description || error)
}
}
useEffect(() => {
supabase.auth.getSession().then(({ data: { session } }) => {
setSession(session)
})
return (
<div className="w-full h-full flex justify-center items-center p-4 bg-gray-300">
<div className="w-full sm:w-1/2 xl:w-1/3">
<div className="border-teal p-8 border-t-12 bg-white mb-6 rounded-lg shadow-lg bg-white">
<div className="mb-4">
<label className="font-bold text-grey-darker block mb-2">Email</label>
<input
type="text"
className="block appearance-none w-full bg-white border border-grey-light hover:border-grey px-2 py-2 rounded shadow"
placeholder="Your Username"
value={username}
onChange={(e) => setUsername(e.target.value)}
const {
data: { subscription },
} = supabase.auth.onAuthStateChange((_event, session) => {
setSession(session)
})
return () => subscription.unsubscribe()
}, [])
if (!session) {
return (
<div className="w-full h-full flex justify-center items-center p-4 bg-gray-300">
<div className="w-full sm:w-1/2 xl:w-1/3">
<div className="border-teal p-8 border-t-12 bg-white mb-6 rounded-lg shadow-lg bg-white">
<Auth
supabaseClient={supabase}
appearance={{ theme: ThemeSupa }}
providers={['github']}
/>
</div>
<div className="mb-4">
<label className="font-bold text-grey-darker block mb-2">Password</label>
<input
type="password"
className="block appearance-none w-full bg-white border border-grey-light hover:border-grey px-2 py-2 rounded shadow"
placeholder="Your password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
</div>
<div className="flex flex-col gap-2">
<a
onClick={(e) => {
e.preventDefault()
handleLogin('SIGNUP', username, password)
}}
href={'/channels'}
className="bg-indigo-700 hover:bg-teal text-white py-2 px-4 rounded text-center transition duration-150 hover:bg-indigo-600 hover:text-white"
>
Sign up
</a>
<a
onClick={(e) => {
e.preventDefault()
handleLogin('LOGIN', username, password)
}}
href={'/channels'}
className="border border-indigo-700 text-indigo-700 py-2 px-4 rounded w-full text-center transition duration-150 hover:bg-indigo-700 hover:text-white"
>
Login
</a>
</div>
</div>
</div>
</div>
)
)
} else {
return <div>Logged in!</div>
}
}
export default Home
@@ -84,5 +84,12 @@ port = 54324
enabled = true
uri = "pg-functions://postgres/public/custom_access_token_hook"
[auth.external.github]
enabled = true
client_id = "env(SUPABASE_AUTH_EXTERNAL_GITHUB_CLIENT_ID)"
secret = "env(SUPABASE_AUTH_EXTERNAL_GITHUB_SECRET)"
redirect_uri = "env(SUPABASE_AUTH_REDIRECT_URI)"
[analytics]
enabled = false