Projet

Général

Profil

0001-registration-only-initialize-model-fields-when-regis.patch

Benjamin Dauvergne, 24 mars 2017 14:14

Télécharger (1,24 ko)

Voir les différences:

Subject: [PATCH] registration: only initialize model fields when registration
 form prefilling is used (fixes #15610)

When prefilling other attributes, it tracebacked on the call to User.__init__().
 src/authentic2/registration_backend/views.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
src/authentic2/registration_backend/views.py
194 194
        if self.token.get('user_id'):
195 195
            kwargs['instance'] = User.objects.get(id=self.token.get('user_id'))
196 196
        else:
197
            kwargs['instance'] = get_user_model()(**attributes)
197
            init_kwargs = {}
198
            for key in ('email', 'first_name', 'last_name', 'ou'):
199
                if key in attributes:
200
                    init_kwargs[key] = attributes[key]
201
            kwargs['instance'] = get_user_model()(**init_kwargs)
198 202

  
199 203
        return kwargs
200 204

  
201
-