Don't crash when migrating users with blank name
authorMagnus Hagander <magnus@hagander.net>
Thu, 8 Dec 2011 18:43:47 +0000 (19:43 +0100)
committerMagnus Hagander <magnus@hagander.net>
Thu, 8 Dec 2011 18:43:47 +0000 (19:43 +0100)
Some users are registered with just a username and no actual name. The
old way only dealt with users with just first or last name - not the
ones completely without name.

pgweb/util/auth.py

index c5fdedd23416ac6010ddf4effe97326d2a278f61..d5934c533c83270a892c5f8ccc86cc86edc0cd68 100644 (file)
@@ -34,6 +34,7 @@ class AuthBackend(ModelBackend):
                                # create a user in the django system, and migrate all settings
                                # we can think of.
                                namepieces = rows[0][2].split(None, 2)
+                               if len(namepieces) == 0: namepieces = ['', '']
                                if len(namepieces) == 1: namepieces.append('')
                                user = User(username=username.lower(), email=rows[0][3], first_name=namepieces[0], last_name=namepieces[1])
                                user.set_password(password)