diff --git a/apps/authentication/views/base.py b/apps/authentication/views/base.py index 7969502c0..c118680f0 100644 --- a/apps/authentication/views/base.py +++ b/apps/authentication/views/base.py @@ -12,6 +12,7 @@ from authentication.mixins import AuthMixin from common.utils import get_logger from common.utils.django import reverse, get_object_or_none from users.models import User +from users.signal_handlers import check_only_allow_exist_user_auth from .mixins import FlashMessageMixin logger = get_logger(__file__) @@ -49,6 +50,11 @@ class BaseLoginCallbackView(AuthMixin, FlashMessageMixin, View): user, create = User.objects.get_or_create( username=user_attr['username'], defaults=user_attr ) + + if not check_only_allow_exist_user_auth(create): + user.delete() + return user, (self.msg_client_err, self.request.error_message) + setattr(user, f'{self.user_type}_id', user_id) if create: setattr(user, 'source', self.user_type)