def get_by_id(id, fields=None, load_org=False): from pritunl import organization user = User(id=id, fields=fields) if not user: return None if load_org: user.org = organization.get_by_id(user.id) return user
def find_user_auth(name, auth_type): from pritunl import organization spec = { 'name': name, 'auth_type': auth_type, } usr = User(None, spec=spec) if not usr: return None usr.org = organization.get_by_id(usr.org_id) if not usr.org: return None return usr
def find_user_auth(name, auth_type): from pritunl import organization spec = { 'name': { '$regex': '^%s$' % re.escape(name), '$options': 'i', }, 'auth_type': auth_type, } usr = User(None, spec=spec) if not usr: return None usr.org = organization.get_by_id(usr.org_id) if not usr.org: return None return usr