]> git.ipfire.org Git - pbs.git/commitdiff
users: Make get_by_email tolerate any stuff around email addresses
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 14 Oct 2022 17:27:21 +0000 (17:27 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 14 Oct 2022 17:27:21 +0000 (17:27 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/users.py

index 9e11fc7be15df07cf9d3072328d9a70b91604194..937a14f4c230df722aff73d639128bbd3c67f899 100644 (file)
@@ -214,7 +214,10 @@ class Users(base.Object):
                # Create a new user
                return self.create(uid)
 
-       def get_by_email(self, email):
+       def get_by_email(self, mail):
+               # Strip any excess stuff from the email address
+               name, mail = email.util.parseaddr(mail)
+
                # Search in LDAP
                res = self._ldap_get(
                        "(&"
@@ -223,7 +226,7 @@ class Users(base.Object):
                                        "(mail=%s)"
                                        "(mailAlternateAddress=%s)"
                                ")"
-                       ")" % (email, email),
+                       ")" % (mail, mail),
                        attrlist=("uid",),
                )