Skip to content

Commit

Permalink
ran formatters and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yadu-M committed Sep 21, 2024
1 parent 111ec7a commit 3c24b1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 4 additions & 3 deletions backend/views/core/auth/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def login_manual(request: HttpRequest):

if not email:
messages.error(request, "Please enter an email")
return redirect_to_login(email, redirect_url)
return redirect_to_login("", redirect_url)

try:
validate_email(email)
except ValidationError:
messages.error(request, "Please enter a valid email")
return redirect_to_login(email, redirect_url)
return redirect_to_login("", redirect_url)

if not password:
messages.error(request, "Please enter a password")
Expand All @@ -74,13 +74,14 @@ def login_manual(request: HttpRequest):
if user.require_change_password: # type: ignore[attr-defined]
messages.warning(request, "You have been requested by an administrator to change your account password.")
return redirect("settings:change_password")

try:
resolve(redirect_url)
return redirect(redirect_url)

Check warning

Code scanning / CodeQL

URL redirection from remote source Medium

Untrusted URL redirection depends on a
user-provided value
.
except Resolver404:
return redirect("dashboard")


def redirect_to_login(email: str, redirect_url: str):
return redirect(f"{reverse('auth:login')}?email={email}&next={redirect_url}")

Check warning

Code scanning / CodeQL

URL redirection from remote source Medium

Untrusted URL redirection depends on a
user-provided value
.

Expand Down
7 changes: 3 additions & 4 deletions frontend/templates/pages/auth/login_initial.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@
}

</style>
<form id="login-form"
method="post"
action="{% url 'auth:login manual' %}">
<form id="login-form" method="post" action="{% url 'auth:login manual' %}">
{% csrf_token %}
<noscript>
<div data-theme="dim"
Expand Down Expand Up @@ -118,7 +116,8 @@ <h2 class="text-2xl font-bold text-center">
placeholder="********"
class="input input-bordered w-full">
</div>
<button id="login-btn" class="btn btn-primary loading-htmx mt-5 w-full"
<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>
Expand Down

0 comments on commit 3c24b1b

Please sign in to comment.