| 1 |
import { |
| 2 |
Navigate, |
| 3 |
useLocation, |
| 4 |
Link |
| 5 |
} from 'react-router-dom' |
| 6 |
import { URLs, pathForPendingFlow, useAuthStatus } from '../auth' |
| 7 |
|
| 8 |
export default function ProviderCallback () { |
| 9 |
const location = useLocation() |
| 10 |
const params = new URLSearchParams(location.search) |
| 11 |
const error = params.get('error') |
| 12 |
const [auth, status] = useAuthStatus() |
| 13 |
|
| 14 |
let url = URLs.LOGIN_URL |
| 15 |
if (status.isAuthenticated) { |
| 16 |
url = URLs.LOGIN_REDIRECT_URL |
| 17 |
} else { |
| 18 |
url = pathForPendingFlow(auth) || url |
| 19 |
} |
| 20 |
if (!error) { |
| 21 |
return <Navigate to={url} /> |
| 22 |
} |
| 23 |
return ( |
| 24 |
<> |
| 25 |
<h1>Third-Party Login Failure</h1> |
| 26 |
<p>Something went wrong.</p> |
| 27 |
<Link to={url}>Continue</Link> |
| 28 |
</> |
| 29 |
) |
| 30 |
} |