login.twig 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. {% extends 'layout.twig' %}
  2. {% block title %}Sign in — IRDB{% endblock %}
  3. {% block guest_content %}
  4. <div class="flex min-h-screen items-center justify-center bg-slate-50 px-4 dark:bg-slate-950">
  5. <div class="w-full max-w-md rounded-2xl border border-slate-200 bg-white p-8 shadow-sm dark:border-slate-800 dark:bg-slate-900">
  6. <div class="mb-6 text-center">
  7. <img src="/assets/logo.svg" alt="IRDB" class="mx-auto h-24 w-24" />
  8. <h1 class="mt-4 font-mono text-2xl font-bold tracking-tight">IRDB</h1>
  9. <p class="mt-1 text-sm text-slate-500 dark:text-slate-400">IP Reputation Database</p>
  10. <p class="mt-3 text-sm text-slate-500 dark:text-slate-400">Sign in to continue</p>
  11. </div>
  12. {% if oidc_enabled %}
  13. <a href="/login/oidc"
  14. class="flex w-full items-center justify-center rounded-md bg-indigo-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-slate-900">
  15. Sign in with Microsoft
  16. </a>
  17. {% endif %}
  18. {% if local_admin_enabled %}
  19. <div class="mt-6" x-data="{ open: {{ oidc_enabled ? 'false' : 'true' }} }">
  20. {% if oidc_enabled %}
  21. <div class="relative my-4 text-center">
  22. <span class="bg-white px-2 text-xs uppercase tracking-wider text-slate-400 dark:bg-slate-900">or</span>
  23. <div class="absolute inset-x-0 top-1/2 -z-10 h-px bg-slate-200 dark:bg-slate-800"></div>
  24. </div>
  25. <button type="button"
  26. x-on:click="open = !open"
  27. class="text-sm text-slate-500 underline hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-200">
  28. <span x-text="open ? 'Hide local sign-in' : 'Use local sign-in'"></span>
  29. </button>
  30. {% endif %}
  31. <form x-show="open"
  32. x-cloak
  33. x-init="$watch('open', (v) => { if (v) $nextTick(() => $refs.usernameInput && $refs.usernameInput.focus()); })"
  34. method="post"
  35. action="/login/local"
  36. class="mt-4 space-y-3">
  37. {% include 'partials/csrf.twig' %}
  38. <div>
  39. <label for="username" class="block text-sm font-medium text-slate-700 dark:text-slate-300">Username</label>
  40. <input type="text" name="username" id="username" x-ref="usernameInput" required autocomplete="username"
  41. {% if not oidc_enabled %}autofocus{% endif %}
  42. class="mt-1 block w-full rounded-md border border-slate-300 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 dark:border-slate-700 dark:bg-slate-950">
  43. </div>
  44. <div>
  45. <label for="password" class="block text-sm font-medium text-slate-700 dark:text-slate-300">Password</label>
  46. <input type="password" name="password" id="password" required autocomplete="current-password"
  47. class="mt-1 block w-full rounded-md border border-slate-300 bg-white px-3 py-2 text-sm shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 dark:border-slate-700 dark:bg-slate-950">
  48. </div>
  49. <button type="submit"
  50. class="flex w-full items-center justify-center rounded-md bg-slate-800 px-4 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-slate-700 focus:outline-none focus:ring-2 focus:ring-slate-500 focus:ring-offset-2 dark:bg-slate-700 dark:hover:bg-slate-600">
  51. Sign in
  52. </button>
  53. </form>
  54. </div>
  55. {% endif %}
  56. {% if not oidc_enabled and not local_admin_enabled %}
  57. <p class="text-sm text-red-600 dark:text-red-400">No sign-in method is enabled. Set <code>OIDC_ENABLED=true</code> or <code>LOCAL_ADMIN_ENABLED=true</code> in the configuration.</p>
  58. {% endif %}
  59. </div>
  60. </div>
  61. {% endblock %}