From 5f3ab495355a50e3c5ca807af4b1ada54d46d4b6 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 25 Feb 2019 14:10:29 +0100 Subject: [PATCH] fix bug when Empty username is given to LoginAttempt.attempt --- passbook/audit/models.py | 2 ++ passbook/core/templates/partials/messages.html | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/passbook/audit/models.py b/passbook/audit/models.py index 6cf4b09a02..810b9e8ee8 100644 --- a/passbook/audit/models.py +++ b/passbook/audit/models.py @@ -84,6 +84,8 @@ class LoginAttempt(CreatedUpdatedModel): @staticmethod def attempt(target_uid, request): """Helper function to create attempt or count up existing one""" + if not target_uid: + return client_ip, _ = get_client_ip(request) # Since we can only use 254 chars for target_uid, truncate target_uid. target_uid = target_uid[:254] diff --git a/passbook/core/templates/partials/messages.html b/passbook/core/templates/partials/messages.html index 3d4f76f213..94b4644daf 100644 --- a/passbook/core/templates/partials/messages.html +++ b/passbook/core/templates/partials/messages.html @@ -1,6 +1,6 @@ {% if messages %} {% for msg in messages %} -
+