diff options
| author | Abeer Upadhyay <ab.esquarer@gmail.com> | 2018-03-25 13:39:32 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-03-28 10:10:18 -0400 |
| commit | 1bf4646f9133f26547a0dccf2f8a4526d85f2ab3 (patch) | |
| tree | b0daff8bfb53294549d1270d73318d0bf4e318ca /django | |
| parent | 76ae1e9a94cbfddbbf115ad96f26901ba5c02d44 (diff) | |
Fixed #29258 -- Added type checking for login()'s backend argument.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/auth/__init__.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py index 590f85442c..6aa900fbe4 100644 --- a/django/contrib/auth/__init__.py +++ b/django/contrib/auth/__init__.py @@ -119,6 +119,9 @@ def login(request, user, backend=None): 'therefore must provide the `backend` argument or set the ' '`backend` attribute on the user.' ) + else: + if not isinstance(backend, str): + raise TypeError('backend must be a dotted import path string (got %r).' % backend) request.session[SESSION_KEY] = user._meta.pk.value_to_string(user) request.session[BACKEND_SESSION_KEY] = backend |
