예제 #1
0
def newGGLUser(email, basic_info, db, access_token):
    import json

    rand_username = ''.join(
        random.choice(string.ascii_uppercase + string.digits)
        for _ in range(10))

    user = User(basic_info['given_name'], basic_info['family_name'], email,
                'google', rand_username, basic_info['picture'])
    db.session.add(user)
    data = db.session.commit()

    newConnection(email, basic_info, db, access_token, user)

    json = user.token_construction()
    return json
예제 #2
0
def newFbUser(basic_info, user_pic, db, access_token):
    import json

    rand_username = ''.join(
        random.choice(string.ascii_uppercase + string.digits)
        for _ in range(10))
    user = User(basic_info['first_name'], basic_info['last_name'],
                basic_info['email'], 'facebook', rand_username,
                user_pic['data']['url'])
    db.session.add(user)
    data = db.session.commit()
    connection = Connections(basic_info['first_name'], basic_info['last_name'],
                             basic_info['email'], 'facebook',
                             user_pic['data']['url'], basic_info['id'],
                             user.id, json.dumps(access_token))

    db.session.add(connection)
    data = db.session.commit()
    if not data:
        json = user.token_construction()

        return json
예제 #3
0
def newTwitterUser(basic_info, db, tokens):
    import json
    name_lst = basic_info['name'].split(' ')
    first_name = name_lst[0]
    last_name = name_lst[1]

    user = User(first_name, last_name, basic_info['id_str'] + '@twit.com',
                'twitter', basic_info['id_str'],
                basic_info['profile_image_url_https'])
    db.session.add(user)
    data = db.session.commit()

    connection = Connections(first_name, last_name,
                             basic_info['id_str'] + '@twit.com', 'twitter',
                             basic_info['profile_image_url_https'],
                             basic_info['id_str'], user.id, json.dumps(tokens))

    db.session.add(connection)
    data = db.session.commit()
    if not data:
        json = user.token_construction()

        return json