@@ -308,3 +308,10 @@ def confirm_oauth_email(user: Any | None = None, *args, **kwargs): if user: user.is_confirmed = True user.save() + + +def detect_email(backend, response, details, **kwargs): + if backend.name == 'yandex-oauth2' and not response.get('email') and response.get('login'): + details['email'] = f'{response['login']}@yandex.ru' + details['username'] = response['login'] + return kwargs | {'backend': backend} | {'response': response} | {'details': details} @@ -127,6 +127,7 @@ SOCIAL_AUTH_ACTIVATE_JWT = True SOCIAL_AUTH_PIPELINE = ( 'social_core.pipeline.social_auth.social_details', + 'authentication.services.user_services.detect_email', 'social_core.pipeline.social_auth.social_uid', 'social_core.pipeline.social_auth.social_user', 'social_core.pipeline.user.get_username',