---
const title = 'Anmeldung wird abgeschlossen...';
---

<html lang="de">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>{title}</title>
  </head>
  <body>
    <p>{title}</p>
    <script>
      (function(){
        try {
          const params = new URLSearchParams(window.location.search);
          const token = params.get('token');
          if (token) {
            const secure = window.location.protocol === 'https:';
            document.cookie = `token=${encodeURIComponent(token)}; Path=/; Max-Age=${60*60*24}; SameSite=Lax; ${secure ? 'Secure' : ''}`.trim();
          }
        } catch(e) {
          console.error('Failed to process OAuth token', e);
        }
        window.location.replace('/admin');
      })();
    </script>
  </body>
  </html>
