@orsetra/shared-auth 1.0.9 → 1.0.11
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.
- package/SessionProvider.tsx +8 -4
- package/ZitadelProvider.tsx +3 -0
- package/components/AuthCallbackError.tsx +58 -0
- package/components/index.ts +2 -0
- package/index.ts +1 -0
- package/package.json +1 -1
package/SessionProvider.tsx
CHANGED
|
@@ -25,14 +25,18 @@ interface SessionProviderProps {
|
|
|
25
25
|
* Utilise ZitadelAuthService pour récupérer l'utilisateur
|
|
26
26
|
*/
|
|
27
27
|
export function SessionProvider({ children, config }: SessionProviderProps) {
|
|
28
|
-
if (!ZitadelAuthService.isConfigured()) {
|
|
29
|
-
ZitadelAuthService.configureAuth(config)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
28
|
const [user, setUser] = useState<User | null>(null)
|
|
33
29
|
const [isLoading, setIsLoading] = useState(true)
|
|
34
30
|
|
|
35
31
|
useEffect(() => {
|
|
32
|
+
// Skip on server-side
|
|
33
|
+
if (typeof window === 'undefined') return
|
|
34
|
+
|
|
35
|
+
// Configure auth only on client side
|
|
36
|
+
if (!ZitadelAuthService.isConfigured()) {
|
|
37
|
+
ZitadelAuthService.configureAuth(config)
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
const loadUser = async () => {
|
|
37
41
|
try {
|
|
38
42
|
const currentUser = await ZitadelAuthService.getUser()
|
package/ZitadelProvider.tsx
CHANGED
|
@@ -32,6 +32,9 @@ export function ZitadelProvider({ children, config }: ZitadelProviderProps) {
|
|
|
32
32
|
const [user, setUser] = useState<User | null>(null)
|
|
33
33
|
|
|
34
34
|
useEffect(() => {
|
|
35
|
+
// Skip on server-side
|
|
36
|
+
if (typeof window === 'undefined') return
|
|
37
|
+
|
|
35
38
|
const configure = async () => {
|
|
36
39
|
try {
|
|
37
40
|
ZitadelAuthService.configureAuth(config)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
interface AuthCallbackErrorProps {
|
|
4
|
+
error: string
|
|
5
|
+
onRetry: () => void
|
|
6
|
+
onBackToWelcome: () => void
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function AuthCallbackError({ error, onRetry, onBackToWelcome }: AuthCallbackErrorProps) {
|
|
10
|
+
return (
|
|
11
|
+
<>
|
|
12
|
+
<div className="text-6xl mb-6 text-center" style={{ color: 'var(--theme-light-warn-500)' }}>
|
|
13
|
+
⚠️
|
|
14
|
+
</div>
|
|
15
|
+
<h1
|
|
16
|
+
className="text-2xl font-semibold mb-4 text-center"
|
|
17
|
+
style={{ color: 'var(--theme-light-text)' }}
|
|
18
|
+
>
|
|
19
|
+
Échec de l'authentification
|
|
20
|
+
</h1>
|
|
21
|
+
<p
|
|
22
|
+
className="mb-8 leading-relaxed text-center"
|
|
23
|
+
style={{ color: 'var(--theme-light-secondary-text)' }}
|
|
24
|
+
>
|
|
25
|
+
{error}
|
|
26
|
+
</p>
|
|
27
|
+
<div className="space-y-3">
|
|
28
|
+
<button
|
|
29
|
+
onClick={onRetry}
|
|
30
|
+
className="w-full font-medium py-3 px-4 transition-colors"
|
|
31
|
+
style={{
|
|
32
|
+
backgroundColor: 'var(--theme-light-primary-500)',
|
|
33
|
+
color: 'var(--theme-light-primary-contrast-500)',
|
|
34
|
+
borderRadius: '0'
|
|
35
|
+
}}
|
|
36
|
+
onMouseEnter={(e) => (e.currentTarget.style.backgroundColor = 'var(--theme-light-primary-600)')}
|
|
37
|
+
onMouseLeave={(e) => (e.currentTarget.style.backgroundColor = 'var(--theme-light-primary-500)')}
|
|
38
|
+
>
|
|
39
|
+
Réessayer la connexion
|
|
40
|
+
</button>
|
|
41
|
+
<button
|
|
42
|
+
onClick={onBackToWelcome}
|
|
43
|
+
className="w-full font-medium py-3 px-4 transition-colors"
|
|
44
|
+
style={{
|
|
45
|
+
backgroundColor: 'var(--theme-light-background-500)',
|
|
46
|
+
color: 'var(--theme-light-text)',
|
|
47
|
+
borderRadius: '0',
|
|
48
|
+
border: '1px solid var(--theme-light-background-600)'
|
|
49
|
+
}}
|
|
50
|
+
onMouseEnter={(e) => (e.currentTarget.style.backgroundColor = 'var(--theme-light-background-600)')}
|
|
51
|
+
onMouseLeave={(e) => (e.currentTarget.style.backgroundColor = 'var(--theme-light-background-500)')}
|
|
52
|
+
>
|
|
53
|
+
Retour à l'accueil
|
|
54
|
+
</button>
|
|
55
|
+
</div>
|
|
56
|
+
</>
|
|
57
|
+
)
|
|
58
|
+
}
|
package/index.ts
CHANGED
|
@@ -10,5 +10,6 @@ export { SessionProvider, useSession } from './SessionProvider'
|
|
|
10
10
|
|
|
11
11
|
// Components
|
|
12
12
|
export { AuthCard, AuthCardTitle, AuthCardDescription, AuthCardSpinner } from './components/AuthCard'
|
|
13
|
+
export { AuthCallbackError } from './components/AuthCallbackError'
|
|
13
14
|
|
|
14
15
|
export * from './utils'
|