2015-07-20 15:39:59 +00:00
|
|
|
from data import model
|
|
|
|
|
|
|
|
class DatabaseUsers(object):
|
2016-10-27 19:31:32 +00:00
|
|
|
@property
|
|
|
|
def federated_service(self):
|
|
|
|
return None
|
|
|
|
|
2017-12-12 21:00:38 +00:00
|
|
|
@property
|
|
|
|
def supports_fresh_login(self):
|
|
|
|
return True
|
|
|
|
|
2017-05-11 03:55:10 +00:00
|
|
|
def ping(self):
|
|
|
|
""" Always assumed to be working. If the DB is broken, other checks will handle it. """
|
|
|
|
return (True, None)
|
|
|
|
|
2017-06-08 17:13:22 +00:00
|
|
|
@property
|
|
|
|
def supports_encrypted_credentials(self):
|
|
|
|
return True
|
|
|
|
|
2017-11-10 21:49:32 +00:00
|
|
|
@property
|
|
|
|
def requires_distinct_cli_password(self):
|
|
|
|
# Since the database stores its own password.
|
|
|
|
return True
|
|
|
|
|
2015-07-20 15:39:59 +00:00
|
|
|
def verify_credentials(self, username_or_email, password):
|
|
|
|
""" Simply delegate to the model implementation. """
|
|
|
|
result = model.user.verify_user(username_or_email, password)
|
|
|
|
if not result:
|
|
|
|
return (None, 'Invalid Username or Password')
|
|
|
|
|
|
|
|
return (result, None)
|
|
|
|
|
|
|
|
def verify_and_link_user(self, username_or_email, password):
|
|
|
|
""" Simply delegate to the model implementation. """
|
|
|
|
return self.verify_credentials(username_or_email, password)
|
|
|
|
|
|
|
|
def confirm_existing_user(self, username, password):
|
|
|
|
return self.verify_credentials(username, password)
|
|
|
|
|
2016-10-27 19:31:32 +00:00
|
|
|
def link_user(self, username_or_email):
|
|
|
|
""" Never used since all users being added are already, by definition, in the database. """
|
|
|
|
return (None, 'Unsupported for this authentication system')
|
|
|
|
|
2018-05-22 18:09:40 +00:00
|
|
|
def get_and_link_federated_user_info(self, user_info, internal_create=False):
|
2017-02-22 02:07:48 +00:00
|
|
|
""" Never used since all users being added are already, by definition, in the database. """
|
|
|
|
return (None, 'Unsupported for this authentication system')
|
|
|
|
|
2016-10-27 19:31:32 +00:00
|
|
|
def query_users(self, query, limit):
|
|
|
|
""" No need to implement, as we already query for users directly in the database. """
|
|
|
|
return (None, '', '')
|
|
|
|
|
2017-02-17 22:10:26 +00:00
|
|
|
def check_group_lookup_args(self, group_lookup_args):
|
|
|
|
""" Never used since all groups, by definition, are in the database. """
|
|
|
|
return (False, 'Not supported')
|
|
|
|
|
|
|
|
def iterate_group_members(self, group_lookup_args, page_size=None, disable_pagination=False):
|
|
|
|
""" Never used since all groups, by definition, are in the database. """
|
|
|
|
return (None, 'Not supported')
|
|
|
|
|
|
|
|
def service_metadata(self):
|
|
|
|
""" Never used since database has no metadata """
|
|
|
|
return {}
|