Rename get_federated_user to get_and_link_federated_user_info

Better to be explicit wherever possible
This commit is contained in:
Joseph Schorr 2017-03-21 13:06:55 -04:00
parent 1a31d98c44
commit bd22fb255e
4 changed files with 9 additions and 9 deletions

View file

@ -175,11 +175,11 @@ class UserAuthentication(object):
"""
return self.state.link_user(username_or_email)
def get_federated_user(self, user_info):
def get_and_link_federated_user_info(self, user_info):
""" Returns a tuple containing the database user record linked to the given UserInformation
pair and any error that occurred when trying to link the user.
"""
return self.state.get_federated_user(user_info)
return self.state.get_and_link_federated_user_info(user_info)
def confirm_existing_user(self, username, password):
""" Verifies that the given password matches to the given DB username. Unlike

View file

@ -24,7 +24,7 @@ class DatabaseUsers(object):
""" Never used since all users being added are already, by definition, in the database. """
return (None, 'Unsupported for this authentication system')
def get_federated_user(self, user_info):
def get_and_link_federated_user_info(self, user_info):
""" Never used since all users being added are already, by definition, in the database. """
return (None, 'Unsupported for this authentication system')

View file

@ -42,10 +42,10 @@ class FederatedUsers(object):
if user_info is None:
return (None, err_msg)
return self.get_federated_user(user_info)
return self.get_and_link_federated_user_info(user_info)
def get_federated_user(self, user_info):
return self._get_federated_user(user_info.username, user_info.email)
def get_and_link_federated_user_info(self, user_info):
return self._get_and_link_federated_user_info(user_info.username, user_info.email)
def verify_and_link_user(self, username_or_email, password):
""" Verifies the given credentials and, if valid, creates/links a database user to the
@ -55,7 +55,7 @@ class FederatedUsers(object):
if credentials is None:
return (None, err_msg)
return self._get_federated_user(credentials.username, credentials.email)
return self._get_and_link_federated_user_info(credentials.username, credentials.email)
def confirm_existing_user(self, username, password):
""" Confirms that the given *database* username and service password are valid for the linked
@ -93,7 +93,7 @@ class FederatedUsers(object):
"""
return (None, 'Not supported')
def _get_federated_user(self, username, email):
def _get_and_link_federated_user_info(self, username, email):
db_user = model.user.verify_federated_login(self._federated_service, username)
if not db_user:
# We must create the user in our db

View file

@ -82,7 +82,7 @@ def sync_team(authentication, stale_team_sync):
continue
# Retrieve the Quay user associated with the member info.
(quay_user, err) = authentication.get_federated_user(member_info)
(quay_user, err) = authentication.get_and_link_federated_user_info(member_info)
if err is not None:
logger.error('Could not link external user %s to an internal user: %s',
member_info.username, err,