Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

1.4 KB
Raw Blame
<Layouts.auth
  heading="Enter your 2FA code"
  subtitle="Open your authenticator app and enter the 6-digit code."
>
  <.auth_container>
    <.form
      :let={f}
      action={~p"/2fa/verify?#{[return_to: @conn.query_params["return_to"]]}"}
      for={@conn.params}
      class="flex flex-col gap-y-6"
      onsubmit="document.getElementById('verify-button').disabled = true"
    >
      <PlausibleWeb.Components.TwoFactor.verify_2fa_input
        form={f}
        field={:code}
        class=""
        autofocus?={true}
        error={@error}
      />

      <div class="flex justify-center items-center">
        <.input
          type="checkbox"
          field={f[:remember_2fa]}
          value="true"
          label={"Remember this device for #{PlausibleWeb.TwoFactor.Session.remember_2fa_days()} days"}
        />
      </div>

      <.input type="hidden" field={f[:return_to]} />
    </.form>

    <div class="mt-6 flex flex-col gap-y-2 text-sm text-gray-500 dark:text-gray-400 text-center">
      <p>
        Can't access your authenticator app?
        <.styled_link href={~p"/2fa/use_recovery_code"}>
          Use a recovery code
        </.styled_link>
      </p>
      <p :if={ee?()}>
        Need help?
        <.styled_link href="https://plausible.io/contact">
          Contact us
        </.styled_link>
      </p>
    </div>
  </.auth_container>
</Layouts.auth>