Make user_import in the django auth plugin return the new user
authorMagnus Hagander <magnus@hagander.net>
Mon, 10 Aug 2020 11:14:33 +0000 (13:14 +0200)
committerMagnus Hagander <magnus@hagander.net>
Mon, 10 Aug 2020 11:15:50 +0000 (13:15 +0200)
It's useful to be able to directly get at the user record that was
returned instead of having to re-query it from the database. Since
nothing was previously returned, this is not backwards incompatible.

tools/communityauth/sample/django/auth.py

index 55eb9b641887fcf06a296ebe1e14eac4f89445ed..96221a3cd88d6e04436c9c84aae03818dab7a933 100644 (file)
@@ -240,9 +240,13 @@ def user_import(uid):
     if User.objects.filter(username=u['u']).exists():
         raise Exception("User already exists")
 
-    User(username=u['u'],
-         first_name=u['f'],
-         last_name=u['l'],
-         email=u['e'],
-         password='setbypluginnotsha1',
-         ).save()
+    u = User(
+        username=u['u'],
+        first_name=u['f'],
+        last_name=u['l'],
+        email=u['e'],
+        password='setbypluginnotsha1',
+    )
+    u.save()
+
+    return u