Пример #1
0
def create_orgs(user):
    """Creates new organization users based on data from GitHub."""
    logger.info('Creating new organization users based on data from GitHub')
    payload = {'access_token': user.github_access_token}
    orgs = github_api_get('/user/orgs', params=payload)
    for org in orgs:
        data = github_api_get('/orgs/%s' % org['login'], params=payload)
        organization = Organization.from_kwargs(**data)
        organization.members.add(user)
        sync_org_account_github(organization, payload)
        logger.info('Organization %s has been created' % organization)
Пример #2
0
def create_user(access_token):
    """Creates a new user based on GitHub's user data."""
    logger.info('Creating a new user based on data from GitHub')
    payload = {'access_token': access_token}
    data = github_api_get('/user', params=payload)
    # Creates a new user based on data from GitHub
    user = User.from_kwargs(github_access_token=access_token, **data)
    # Authenticate and sign in the user
    user = authenticate(access_token=access_token)
    logger.info('Created a new user %s.' % user)
    subject = 'New user %s' % user
    message = 'http://www.hasdocs.com/%s\nhttps://github.com/%s' % (user, user)
    Thread(target=mail_managers, args=(subject, message)).start()
    return user