Skip to content

Commit

Permalink
Bringing back the Login Experience
Browse files Browse the repository at this point in the history
  • Loading branch information
justsoantsy committed Sep 4, 2024
1 parent 0468c30 commit 7288f0c
Show file tree
Hide file tree
Showing 3 changed files with 480 additions and 58 deletions.
26 changes: 11 additions & 15 deletions apps/web/src/pages/login.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import Logo from '@components/Common/Logo'
import MetaTags from '@components/Common/MetaTags'
import Authenticate from '@components/Login/Authenticate'
import Connectors from '@components/Login/Connectors'
import { EVENTS, Tower } from '@dragverse/generic'
import { usePrivy } from '@privy-io/react-auth'
import Link from 'next/link'
import { useEffect } from 'react'
import { useEffect, useState } from 'react'

const Login = () => {
const { login, authenticated, ready } = usePrivy()
const [isAuthenticated, setIsAuthenticated] = useState(false)

useEffect(() => {
Tower.track(EVENTS.PAGEVIEW, { page: EVENTS.PAGE_VIEW.LOGIN })
setIsAuthenticated(false)
}, [])

const handleLogin = async () => {
if (!authenticated) {
await login()
}
// After successful login, you can redirect or perform other actions
const handleAuthentication = (status: boolean) => {
setIsAuthenticated(status)
}

return (
Expand All @@ -37,13 +36,10 @@ const Login = () => {
The most ✨ iconic ✨ version of yourself online
</p>
</div>
{ready && (
<button
onClick={handleLogin}
className="w-full rounded-lg bg-blue-500 px-4 py-2 text-white hover:bg-blue-600"
>
{authenticated ? 'Connected' : 'Login with Privy'}
</button>
{!isAuthenticated ? (
<Connectors onAuthenticated={handleAuthentication} />
) : (
<Authenticate />
)}
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@
"engines": {
"node": ">=16.18.1 <=19.0.0"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"dependencies": {
"@privy-io/react-auth": "^1.81.3"
}
}
Loading

0 comments on commit 7288f0c

Please sign in to comment.