diff --git a/app/views/auth.py b/app/views/auth.py
index f40d6247b665b17c87a169bf837cad114f38d67f..7cd0cfb570b043d1cbbbaf17e85e08f1ab64cab3 100644
--- a/app/views/auth.py
+++ b/app/views/auth.py
@@ -43,6 +43,7 @@ def login():
         if attributes is None:
             flash(messages.LOGIN_UNSUCCESSFUL_ERROR)
             return render_template("pages/login.html", form=form)
+        username = attributes["name"]
         user = AuthenticatedUser.query.filter_by(username=username).first()
         if not user:
             user = AuthenticatedUser(