Initial interfaces and support for team syncing worker

This commit is contained in:
Joseph Schorr 2017-02-21 21:07:48 -05:00
parent 94b07e6de9
commit eeadeb9383
12 changed files with 282 additions and 15 deletions

View file

@ -175,6 +175,12 @@ class UserAuthentication(object):
"""
return self.state.link_user(username_or_email)
def get_federated_user(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)
def confirm_existing_user(self, username, password):
""" Verifies that the given password matches to the given DB username. Unlike
verify_credentials, this call first translates the DB user via the FederatedLogin table

View file

@ -24,6 +24,10 @@ 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):
""" Never used since all users being added are already, by definition, in the database. """
return (None, 'Unsupported for this authentication system')
def query_users(self, query, limit):
""" No need to implement, as we already query for users directly in the database. """
return (None, '', '')

View file

@ -38,11 +38,14 @@ class FederatedUsers(object):
return (None, 'Not supported')
def link_user(self, username_or_email):
(credentials, err_msg) = self.get_user(username_or_email)
if credentials is None:
(user_info, err_msg) = self.get_user(username_or_email)
if user_info is None:
return (None, err_msg)
return self._get_federated_user(credentials.username, credentials.email)
return self.get_federated_user(user_info)
def get_federated_user(self, user_info):
return self._get_federated_user(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
@ -111,7 +114,7 @@ class FederatedUsers(object):
prompts=prompts)
else:
# Update the db attributes from the federated service.
if email:
if email and db_user.email != email:
db_user.email = email
db_user.save()