import Head from 'next/head'; import { useEffect, useRef, useState } from 'react'; import type { FormEvent } from 'react'; import { useRouter } from 'next/router'; export default function Login() { const router = useRouter(); const { id, audience, acsUrl, providerName, relayState } = router.query; const [email, setEmail] = useState('jackson'); // Set focus to email input on load const emailInp = useRef(null); useEffect(() => { if (emailInp.current) { emailInp.current.focus(); emailInp.current.select(); } }, []); const handleChange = (e: FormEvent): void => { setEmail(e.currentTarget.value); }; const handleSubmit = async (e: FormEvent) => { e.preventDefault(); const response = await fetch(`/api/saml/auth`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ email: `${email}@example.com`, id, audience, acsUrl, providerName, relayState }), }); if (response.ok) { const newHtml = await response.text(); const newDoc = document.open('text/html', 'replace'); newDoc.write(newHtml); newDoc.close(); } else { document.write('Error in getting SAML response'); } }; return (
Mock SAML IdP - Login

Login

@example.com
); }