@luxfi/core 4.4.12 → 4.4.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,14 +8,20 @@ const AuthListener = () => {
8
8
  const auth = useAuth()
9
9
 
10
10
  useEffect(() => {
11
- const authToken = getCookie('auth-token')
12
- if (!!authToken) {
13
- auth.loginWithCustomToken(authToken)
14
- }
15
- else {
16
- auth.logout()
17
- }
18
- }, [])
11
+ fetch(`${process.env.NEXT_PUBLIC_LOGIN_SITE_URL}/api/auth/get-auth-token`, {
12
+ method: 'GET',
13
+ credentials: 'include',
14
+ })
15
+ .then(response => response.json())
16
+ .then((data: any) => {
17
+ const token = getCookie('auth-token')
18
+ console.log(data)
19
+ console.log(token)
20
+ if (!!token) {
21
+ auth.loginWithCustomToken(token)
22
+ }
23
+ })
24
+ }, [auth])
19
25
 
20
26
  return ( <></> )
21
27
  }
@@ -1,10 +1,8 @@
1
1
  'use client'
2
2
 
3
- import { useState } from 'react'
4
- import { useRouter } from 'next/navigation'
5
3
  import Link from 'next/link'
6
4
  import Autoplay from 'embla-carousel-autoplay'
7
- import { getCookie } from 'cookies-next'
5
+ import { setCookie } from 'cookies-next'
8
6
 
9
7
  import { cn } from '@hanzo/ui/util'
10
8
  import { Button, Carousel, CarouselContent, CarouselItem } from '@hanzo/ui/primitives'
@@ -13,9 +11,7 @@ import { LoginPanel as Login } from '@hanzo/auth/components'
13
11
  import { Logo } from '..'
14
12
  import LuxLogo from '../icons/lux-logo'
15
13
  import { legal } from '../../site-def/footer'
16
- import domains from './common-auth-domains'
17
- import SetAuthToken from './auth-token/set-auth-token'
18
- import ClearAuthToken from './auth-token/clear-auth-token'
14
+ import { useRouter } from 'next/navigation'
19
15
 
20
16
  const LoginPanel: React.FC<{
21
17
  close: () => void
@@ -32,35 +28,18 @@ const LoginPanel: React.FC<{
32
28
  }) => {
33
29
  const router = useRouter()
34
30
 
35
- const [authToken, setAuthToken] = useState<string>(getCookie('auth-token') ?? '')
36
-
37
31
  const termsOfServiceUrl = legal.find(({title}) => title === 'Terms and Conditions')?.href || ''
38
32
  const privacyPolicyUrl = legal.find(({title}) => title === 'Privacy Policy')?.href || ''
39
33
 
40
34
  const onLogin = (token: string) => {
41
- setAuthToken(token)
42
-
43
- const promises = domains.map(({url}) => {
44
- return new Promise<void>((resolve, reject) => {
45
- const img = new Image()
46
- img.onload = () => {
47
- document.body.appendChild(img)
48
- resolve()
49
- }
50
- img.onerror = reject
51
- img.src = url
52
- })
35
+ setCookie('auth-token', token, {
36
+ expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30), // 30 days
53
37
  })
54
-
55
- Promise.all(promises)
56
- .then(() => redirectUrl && router.replace(redirectUrl))
57
- .catch(error => console.error('An image failed to load', error));
38
+
39
+ redirectUrl && router.push(redirectUrl)
58
40
  }
59
41
 
60
42
  return (<>
61
- {!!authToken && <SetAuthToken authToken={authToken} />}
62
- {!authToken && <ClearAuthToken />}
63
-
64
43
  <div className={cn('grid grid-cols-1 md:grid-cols-2', className)}>
65
44
  <div className='hidden md:flex w-full h-full bg-level-1 flex-row items-end justify-end overflow-y-auto min-h-screen'>
66
45
  <div className='h-full w-full max-w-[750px] px-8 pt-0'>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxfi/core",
3
- "version": "4.4.12",
3
+ "version": "4.4.14",
4
4
  "description": "Library that contains shared UI primitives, support for a common design system, and other boilerplate support.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",