-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: removed email to password redirect * fix: added password into initial login page
- Loading branch information
Showing
2 changed files
with
79 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,13 +65,12 @@ | |
color: inherit; | ||
} | ||
|
||
.btn-loading { | ||
background: url(https://raw.githubusercontent.com/n3r4zzurr0/svg-spinners/main/preview/90-ring-with-bg-white-36.svg) no repeat 50% 50%; | ||
} | ||
|
||
</style> | ||
<form method="post" | ||
class="slide-transition" | ||
hx-swap="none" | ||
hx-post="{% url 'auth:login manual' %}" | ||
action="{% url 'auth:login manual' %}"> | ||
<form id="login-form" method="post" action="{% url 'auth:login manual' %}"> | ||
{% csrf_token %} | ||
<noscript> | ||
<div data-theme="dim" | ||
|
@@ -90,29 +89,51 @@ <h2 class="text-2xl font-bold text-center"> | |
</div> | ||
</div> | ||
</noscript> | ||
<div data-swap="form_fields"> | ||
<div class="form-control w-full mt-4"> | ||
<label class="label"> | ||
<span class="label-text text-base-content undefined">Email Address</span> | ||
</label> | ||
<input required | ||
type="email" | ||
name="email" | ||
pattern="[^@\s]+@[^@\s]+\.[^@\s]+" | ||
placeholder="[email protected]" | ||
class="peer input input-bordered w-full" | ||
value="{{ attempted_email|default_if_none:'' }}"> | ||
<label class="label peer-[&:not(:placeholder-shown):not(:focus):invalid]:block hidden"> | ||
<span class="label-text-alt text-error">Please enter a valid email.</span> | ||
</label> | ||
<input type="hidden" name="page" value="1"> | ||
<input type="hidden" name="next" value="{{ request.GET.next }}"> | ||
</div> | ||
<button hx-swap="none" hx-target="form" class="btn mt-6 w-full btn-primary"> | ||
Next | ||
<i class="fa-solid fa-arrow-right"></i> | ||
</button> | ||
<div class="form-control w-full mt-4"> | ||
<label class="label"> | ||
<span class="label-text text-base-content undefined">Email Address</span> | ||
</label> | ||
<input required | ||
type="email" | ||
name="email" | ||
pattern="[^@\s]+@[^@\s]+\.[^@\s]+" | ||
placeholder="[email protected]" | ||
class="peer input input-bordered w-full" | ||
value="{{ request.GET.email|default_if_none:'' }}"> | ||
<label class="label peer-[&:not(:placeholder-shown):not(:focus):invalid]:block hidden"> | ||
<span class="label-text-alt text-error">Please enter a valid email.</span> | ||
</label> | ||
<input type="hidden" name="next" value="{{ request.GET.next }}"> | ||
</div> | ||
<div class="form-control w-full mt-4"> | ||
<label class="label"> | ||
<span class="label-text text-base-content undefined">Password</span> | ||
</label> | ||
<input required | ||
autofocus | ||
type="password" | ||
name="password" | ||
placeholder="********" | ||
class="input input-bordered w-full"> | ||
</div> | ||
<button id="login-btn" | ||
class="btn btn-primary loading-htmx mt-5 w-full" | ||
data-hx-loading="save" | ||
type="submit"> | ||
<span class="loading-htmx-text">Login</span> | ||
<span id="currency_save_loading" | ||
class="loading loading-spinner loading-htmx-loader"></span> | ||
</button> | ||
<div class="divider mt-8">OR</div> | ||
{% if magic_links_enabled %} | ||
<button type="button" | ||
hx-post="{% url 'auth:login magic_link request' %}" | ||
hx-vals='{"email": "{{ email }}", "next": "{{ next }}"}' | ||
class="btn-large-card flex flex-col items-center"> | ||
<span>Login with email magic link</span> | ||
<span class="text-xs text-center">This sends an email to your address, all you need to do is press the link and you're in!</span> | ||
</button> | ||
{% endif %} | ||
<div class="text-center mt-3"> | ||
Don't have an account yet? | ||
<a href="{% url 'auth:login create_account' %}" | ||
|
@@ -136,4 +157,14 @@ <h2 class="text-2xl font-bold text-center"> | |
</a> | ||
{% endif %} | ||
</form> | ||
<script> | ||
// Displays loader and disables button when form is submitted | ||
const form = document.getElementById("login-form"); | ||
form.addEventListener("submit", (event) => { | ||
const button = document.getElementById("login-btn"); | ||
const loader = document.getElementById("currency_save_loading"); | ||
button.setAttribute("disabled", ""); | ||
loader.style.display = "inline-block"; | ||
}) | ||
</script> | ||
{% endblock %} |