Skip to content

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

1.9 KB
Raw Blame
<.focus_box>
  <:title>
    Setup Two-Factor Authentication
  </:title>

  <:subtitle>
    <.notice :if={@forced?} class="mb-2" theme={:gray} title="Team requires 2FA setup">
      You've been redirected here because your team enforces 2FA. Please complete the setup or switch to another team.
    </.notice>
    Link your Plausible account to the authenticator app you have installed either on your phone or computer.
  </:subtitle>

  <:footer :if={not @forced?}>
    <.focus_list>
      <:item>
        Changed your mind?
        <.styled_link href={~p"/settings/security#update-2fa"}>
          Go back to Settings
        </.styled_link>
      </:item>
    </.focus_list>
  </:footer>

  <div class="flex flex-col sm:flex-row items-center sm:items-start">
    <div class="border-2 border-gray-300 inline-block p-2 dark:bg-white">
      <PlausibleWeb.Components.TwoFactor.qr_code text={@totp_uri} />
    </div>

    <div class="sm:ml-4">
      <.focus_list>
        <:item>
          Open the authenticator application
        </:item>
        <:item>
          Tap Scan a QR Code
        </:item>
        <:item>
          Scan this code with your phone camera or paste the code manually
        </:item>
      </.focus_list>
      <div class="sm:ml-2">
        <PlausibleWeb.Live.Components.Form.input_with_clipboard
          id="secret"
          name="secret_clipboard"
          label="Code"
          value={@secret}
          onfocus="this.value = this.value;"
          class="focus:ring-indigo-500 focus:border-indigo-500 bg-gray-50 dark:bg-gray-850 dark:text-gray-300 block w-7/12 rounded-md sm:text-sm border-gray-300 dark:border-gray-500 w-full p-2 mt-2"
        />
      </div>
    </div>
  </div>

  <div class="mt-6 flex flex-col-reverse sm:flex-row justify-between items-center">
    <.unstyled_link
      id="proceed"
      class="button w-full"
      href={~p"/2fa/setup/verify"}
    >
      Proceed
    </.unstyled_link>
  </div>
</.focus_box>