From ee7dd91bc55a8e0570280af61d1e8d9c146addb9 Mon Sep 17 00:00:00 2001
From: PedroHenriqueDevBR
Date: Wed, 10 Jan 2024 08:38:21 -0300
Subject: [PATCH] fix: remove mail from username data
---
ldap_password/apps/core/views.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/ldap_password/apps/core/views.py b/ldap_password/apps/core/views.py
index 41dda65..ec77c86 100644
--- a/ldap_password/apps/core/views.py
+++ b/ldap_password/apps/core/views.py
@@ -60,8 +60,14 @@ def create_context(self, data: QueryDict):
context["repeate_password"] = data.get("repeate_password")
return context
+ def format_username(self, username):
+ if "@" not in username:
+ return username
+ username_splited = username.split("@")
+ return username_splited[0]
+
def change_ldap_password(self, request: HttpRequest, data: QueryDict):
- username = data.get("username") or ""
+ username = self.format_username(data.get("username") or "")
current_password = data.get("current_password") or ""
new_password = data.get("new_password") or ""
ldap_search = SearchLDAPUser()