From b97aa1d581946c1b601cd5002fbe290b717ae59f Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Mon, 10 Aug 2020 13:14:33 +0200 Subject: [PATCH] Make user_import in the django auth plugin return the new user 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 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/communityauth/sample/django/auth.py b/tools/communityauth/sample/django/auth.py index 55eb9b64..96221a3c 100644 --- a/tools/communityauth/sample/django/auth.py +++ b/tools/communityauth/sample/django/auth.py @@ -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 -- 2.39.5