Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 1x 4x 4x 4x 4x 4x 4x 4x 2x 2x 2x 2x 2x 2x 2x 4x | import { useEffect } from 'react'
import { useNavigate, useSearchParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
export const AuthSuccessPage = () => {
const { t } = useTranslation('common')
const [searchParams] = useSearchParams()
const navigate = useNavigate()
useEffect(() => {
const token = searchParams.get('token')
const userJson = searchParams.get('user')
if (token) {
localStorage.setItem('token', token)
Eif (userJson) {
try {
// Decode safely before storing if needed, or just store raw if apps expects raw
// The backend sent encoded URI component, searchParams decodes it automatically
localStorage.setItem('user', userJson)
} catch (e) {
console.error('Failed to parse user data', e)
}
}
navigate('/')
} else {
console.error('No token found in URL')
navigate('/login')
}
}, [searchParams, navigate])
return (
<div className="flex items-center justify-center min-h-screen">
<div className="text-xl">{t('login.logging_in')}</div>
</div>
)
}
|