Merge pull request #217 from edx/ahtisham/PROD-1916-p

Error incase of disabled user social login
This commit is contained in:
Ahtisham Shahid
2021-01-13 16:24:02 +05:00
committed by GitHub
8 changed files with 87 additions and 8 deletions

View File

@@ -71,6 +71,7 @@ import six
import social_django
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth import logout
from django.core.mail.message import EmailMessage
from django.http import HttpResponseBadRequest
from django.shortcuts import redirect
@@ -674,10 +675,11 @@ def set_logged_in_cookies(backend=None, user=None, strategy=None, auth_entry=Non
"""
if not is_api(auth_entry) and user is not None and user.is_authenticated:
request = strategy.request if strategy else None
if not user.has_usable_password():
msg = "Your account is disabled"
logout(request)
return JsonResponse(msg, status=403)
request = strategy.request if strategy else None
# n.b. for new users, user.is_active may be False at this point; set the cookie anyways.
if request is not None:
# Check that the cookie isn't already set.