/usr/lib/python3/dist-packages/social/backends/legacy.py is in python3-social-auth 0.2.13-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | from social.backends.base import BaseAuth
from social.exceptions import AuthMissingParameter
class LegacyAuth(BaseAuth):
def get_user_id(self, details, response):
return details.get(self.ID_KEY) or \
response.get(self.ID_KEY)
def auth_url(self):
return self.setting('FORM_URL')
def auth_html(self):
return self.strategy.render_html(tpl=self.setting('FORM_HTML'))
def uses_redirect(self):
return self.setting('FORM_URL') and not \
self.setting('FORM_HTML')
def auth_complete(self, *args, **kwargs):
"""Completes loging process, must return user instance"""
if self.ID_KEY not in self.data:
raise AuthMissingParameter(self, self.ID_KEY)
kwargs.update({'response': self.data, 'backend': self})
return self.strategy.authenticate(*args, **kwargs)
def get_user_details(self, response):
"""Return user details"""
email = response.get('email', '')
username = response.get('username', '')
fullname, first_name, last_name = self.get_user_names(
response.get('fullname', ''),
response.get('first_name', ''),
response.get('last_name', '')
)
if email and not username:
username = email.split('@', 1)[0]
return {
'username': username,
'email': email,
'fullname': fullname,
'first_name': first_name,
'last_name': last_name
}
|