@luxfi/core 4.4.12 → 4.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,20 +2,24 @@
|
|
2
2
|
|
3
3
|
import { useEffect } from 'react'
|
4
4
|
import { useAuth } from '@hanzo/auth/service'
|
5
|
-
import { getCookie } from 'cookies-next'
|
6
5
|
|
7
6
|
const AuthListener = () => {
|
8
7
|
const auth = useAuth()
|
9
8
|
|
10
9
|
useEffect(() => {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
fetch(`${process.env.NEXT_PUBLIC_LOGIN_SITE_URL}/api/auth/get-auth-token`, {
|
11
|
+
method: 'GET',
|
12
|
+
credentials: 'include',
|
13
|
+
})
|
14
|
+
.then(response => response.json())
|
15
|
+
.then((data: any) => {
|
16
|
+
console.log(data)
|
17
|
+
if (!!data.token) {
|
18
|
+
|
19
|
+
auth.loginWithCustomToken(data.token)
|
20
|
+
}
|
21
|
+
})
|
22
|
+
}, [auth])
|
19
23
|
|
20
24
|
return ( <></> )
|
21
25
|
}
|
@@ -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 {
|
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,6 @@ 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'
|
19
14
|
|
20
15
|
const LoginPanel: React.FC<{
|
21
16
|
close: () => void
|
@@ -30,37 +25,16 @@ const LoginPanel: React.FC<{
|
|
30
25
|
className='',
|
31
26
|
reviews
|
32
27
|
}) => {
|
33
|
-
const router = useRouter()
|
34
|
-
|
35
|
-
const [authToken, setAuthToken] = useState<string>(getCookie('auth-token') ?? '')
|
36
|
-
|
37
28
|
const termsOfServiceUrl = legal.find(({title}) => title === 'Terms and Conditions')?.href || ''
|
38
29
|
const privacyPolicyUrl = legal.find(({title}) => title === 'Privacy Policy')?.href || ''
|
39
30
|
|
40
31
|
const onLogin = (token: string) => {
|
41
|
-
|
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
|
-
})
|
32
|
+
setCookie('auth-token', token, {
|
33
|
+
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30), // 30 days
|
53
34
|
})
|
54
|
-
|
55
|
-
Promise.all(promises)
|
56
|
-
.then(() => redirectUrl && router.replace(redirectUrl))
|
57
|
-
.catch(error => console.error('An image failed to load', error));
|
58
35
|
}
|
59
36
|
|
60
37
|
return (<>
|
61
|
-
{!!authToken && <SetAuthToken authToken={authToken} />}
|
62
|
-
{!authToken && <ClearAuthToken />}
|
63
|
-
|
64
38
|
<div className={cn('grid grid-cols-1 md:grid-cols-2', className)}>
|
65
39
|
<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
40
|
<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.
|
3
|
+
"version": "4.4.13",
|
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/",
|