]> git.ipfire.org Git - ipfire.org.git/commitdiff
accounts: Do not fail when an account has already been created
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 Oct 2019 16:00:36 +0000 (17:00 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 Oct 2019 16:00:36 +0000 (17:00 +0100)
When people choose a password that is too weak, the account might
already have been created and a second attempt will fail.

This prevents that.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/accounts.py

index 9d72b1cbfe4babb8aa68f54590aea245dec41ffa..d36dbafbbc3d50d8dc85101a09699577af72bc10 100644 (file)
@@ -218,6 +218,11 @@ class Accounts(Object):
                if not res:
                        return
 
+               # Return the account if it has already been created
+               account = self.get_by_uid(uid)
+               if account:
+                       return account
+
                # Create a new account on the LDAP database
                account = self.create(uid, res.email,
                        first_name=res.first_name, last_name=res.last_name,