Example #1
0
def retrieve_user_from_twitter(response):
    auth_id = 'twitter_%s' % response['user_id']
    user_db = model.User.get_by('auth_ids', auth_id)
    return user_db or auth.create_or_get_user_db(
        auth_id=auth_id,
        name=response['screen_name'],
        username=response['screen_name'],
        verified=True)
Example #2
0
def retrieve_user_from_vk(response):
    auth_id = "vk_%s" % response["uid"]
    user_db = model.User.get_by("auth_ids", auth_id)
    if user_db:
        return user_db

    name = " ".join((response["first_name"], response["last_name"])).strip()
    return auth.create_or_get_user_db(auth_id=auth_id, name=name, username=name, verified=True)
Example #3
0
def retrieve_user_from_twitter(response):
    auth_id = 'twitter_%s' % response['user_id']
    user_db = model.User.get_by('auth_ids', auth_id)
    return user_db or auth.create_or_get_user_db(
        auth_id=auth_id,
        name=response['screen_name'],
        username=response['screen_name'],
        verified=True
    )
Example #4
0
def retrieve_user_from_microsoft(response):
    auth_id = "microsoft_%s" % response["id"]
    user_db = model.User.get_by("auth_ids", auth_id)
    if user_db:
        return user_db
    email = response["emails"]["preferred"] or response["emails"]["account"]
    return auth.create_or_get_user_db(
        auth_id=auth_id, name=response.get("name", ""), username=email, email=email, verified=True
    )
Example #5
0
def retrieve_user_from_facebook(response):
    auth_id = 'facebook_%s' % response['id']
    user_db = model.User.get_by('auth_ids', auth_id)
    return user_db or auth.create_or_get_user_db(
        auth_id=auth_id,
        name=response['name'],
        username=response.get('username', response['name']),
        email=response.get('email', ''),
        verified=True,
        facebook=response.get('id'))
Example #6
0
def retrieve_user_from_vk(response):
    auth_id = 'vk_%s' % response['uid']
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        return user_db

    name = ' '.join((response['first_name'], response['last_name'])).strip()
    return auth.create_or_get_user_db(auth_id=auth_id,
                                      name=name,
                                      username=name,
                                      verified=True)
Example #7
0
def retrieve_user_from_facebook(response):
    auth_id = 'facebook_%s' % response['id']
    user_db = model.User.get_by('auth_ids', auth_id)
    return user_db or auth.create_or_get_user_db(
        auth_id=auth_id,
        name=response['name'],
        username=response.get('username', response['name']),
        email=response.get('email', ''),
        verified=True,
        facebook=response.get('id')
    )
Example #8
0
def retrieve_user_from_dropbox(response):
    auth_id = 'dropbox_%s' % response['uid']
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        return user_db

    return auth.create_or_get_user_db(auth_id=auth_id,
                                      email=response['email'],
                                      name=response['display_name'],
                                      username=response['display_name'],
                                      verified=True)
Example #9
0
def retrieve_user_from_instagram(response):
    auth_id = 'instagram_%s' % response['id']
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        return user_db

    return auth.create_or_get_user_db(
        auth_id=auth_id,
        name=response.get('full_name', '').strip() or response.get('username'),
        username=response.get('username'),
        verified=True
    )
Example #10
0
def retrieve_user_from_instagram(response):
    auth_id = 'instagram_%s' % response['id']
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        return user_db

    return auth.create_or_get_user_db(
        auth_id=auth_id,
        name=response.get('full_name', '').strip() or response.get('username'),
        username=response.get('username'),
        verified=True
    )
Example #11
0
def retrieve_user_from_microsoft(response):
    auth_id = 'microsoft_%s' % response['id']
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        return user_db
    email = response['emails']['preferred'] or response['emails']['account']
    return auth.create_or_get_user_db(
        auth_id=auth_id,
        name=response.get('name', ''),
        username=email,
        email=email,
        verified=True,
    )
Example #12
0
def retrieve_user_from_microsoft(response):
    auth_id = 'microsoft_%s' % response['id']
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        return user_db
    email = response['emails']['preferred'] or response['emails']['account']
    return auth.create_or_get_user_db(
        auth_id=auth_id,
        name=response.get('name', ''),
        username=email,
        email=email,
        verified=True,
    )
Example #13
0
def retrieve_user_from_vk(response):
    auth_id = 'vk_%s' % response['uid']
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        return user_db

    name = ' '.join((response['first_name'], response['last_name'])).strip()
    return auth.create_or_get_user_db(
        auth_id=auth_id,
        name=name,
        username=name,
        verified=True
    )
Example #14
0
def retrieve_user_from_dropbox(response):
    auth_id = 'dropbox_%s' % response['uid']
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        return user_db

    return auth.create_or_get_user_db(
        auth_id=auth_id,
        email=response['email'],
        name=response['display_name'],
        username=response['display_name'],
        verified=True
    )
Example #15
0
def retrieve_user_from_github(response):
    auth_id = 'github_%s' % str(response['id'])
    user_db = model.User.get_by('auth_ids', auth_id)
    bio = response['bio'][:UserValidator.bio[1]] if response['bio'] else ''
    location = response['location'][:UserValidator.location[1]] if response[
        'location'] else ''
    return user_db or auth.create_or_get_user_db(auth_id,
                                                 response.get('name', ''),
                                                 response.get('login'),
                                                 response.get('email', ''),
                                                 verified=True,
                                                 location=location,
                                                 bio=bio,
                                                 github=response.get('login'))
def retrieve_user_from_bitbucket(response):
    auth_id = "bitbucket_%s" % response["username"]
    user_db = model.User.get_by("auth_ids", auth_id)
    if user_db:
        return user_db
    if response["first_name"] or response["last_name"]:
        name = " ".join((response["first_name"], response["last_name"])).strip()
    else:
        name = ""
    emails = bitbucket.get("users/%s/emails" % response["username"])
    email = "".join([e["email"] for e in emails.data if e["primary"]][0:1])
    return auth.create_or_get_user_db(
        auth_id=auth_id, name=name, username=response["username"], email=email, verified=True
    )
Example #17
0
def retrieve_user_from_github(response):
    auth_id = 'github_%s' % str(response['id'])
    user_db = model.User.get_by('auth_ids', auth_id)
    bio = response['bio'][:UserValidator.bio[1]] if response['bio'] else ''
    location = response['location'][:UserValidator.location[1]] if response['location'] else ''
    return user_db or auth.create_or_get_user_db(
        auth_id,
        response.get('name', ''),
        response.get('login'),
        response.get('email', ''),
        verified=True,
        location=location,
        bio=bio,
        github=response.get('login')
    )
Example #18
0
def retrieve_user_from_linkedin(response):
    auth_id = 'linkedin_%s' % response['id']
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        return user_db

    names = [response.get('firstName', ''), response.get('lastName', '')]
    name = ' '.join(names).strip()
    email = response.get('emailAddress', '')
    return auth.create_or_get_user_db(
        auth_id=auth_id,
        name=name,
        username=email or name,
        email=email,
        verified=True,
    )
Example #19
0
def retrieve_user_from_linkedin(response):
    auth_id = 'linkedin_%s' % response['id']
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        return user_db

    names = [response.get('firstName', ''), response.get('lastName', '')]
    name = ' '.join(names).strip()
    email = response.get('emailAddress', '')
    return auth.create_or_get_user_db(
        auth_id=auth_id,
        name=name,
        username=email or name,
        email=email,
        verified=True,
    )
Example #20
0
def retrieve_user_from_google(google_user):
    auth_id = 'federated_%s' % google_user.user_id()
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        if not user_db.admin and users.is_current_user_admin():
            user_db.admin = True
            user_db.put()
        return user_db

    return auth.create_or_get_user_db(
        auth_id=auth_id,
        name=util.create_name_from_email(google_user.email()),
        username=google_user.email(),
        email=google_user.email(),
        verified=True,
        admin=users.is_current_user_admin(),
    )
Example #21
0
def retrieve_user_from_bitbucket(response):
    auth_id = 'bitbucket_%s' % response['username']
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        return user_db
    if response['first_name'] or response['last_name']:
        name = ' '.join((response['first_name'], response['last_name'])).strip()
    else:
        name = ''
    emails = bitbucket.get('users/%s/emails' % response['username'])
    email = ''.join([e['email'] for e in emails.data if e['primary']][0:1])
    return auth.create_or_get_user_db(
        auth_id=auth_id,
        name=name,
        username=response['username'],
        email=email,
        verified=True,
    )
Example #22
0
def retrieve_user_from_bitbucket(response):
    auth_id = 'bitbucket_%s' % response['username']
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        return user_db
    if response['first_name'] or response['last_name']:
        name = ' '.join(
            (response['first_name'], response['last_name'])).strip()
    else:
        name = ''
    emails = bitbucket.get('users/%s/emails' % response['username'])
    email = ''.join([e['email'] for e in emails.data if e['primary']][0:1])
    return auth.create_or_get_user_db(
        auth_id=auth_id,
        name=name,
        username=response['username'],
        email=email,
        verified=True,
    )
Example #23
0
def retrieve_user_from_yahoo(response):
    auth_id = 'yahoo_%s' % response['guid']
    user_db = model.User.get_by('auth_ids', auth_id)
    if user_db:
        return user_db

    names = [response.get('givenName', ''), response.get('familyName', '')]
    emails = response.get('emails', {})
    if not isinstance(emails, list):
        emails = [emails]
    emails = [e for e in emails if 'handle' in e]
    emails.sort(key=lambda e: e.get('primary', False))
    email = emails[0]['handle'] if emails else ''
    return auth.create_or_get_user_db(
        auth_id=auth_id,
        name=' '.join(names).strip() or response['nickname'],
        username=response['nickname'],
        email=email,
        verified=True,
    )
def retrieve_user_from_twitter(response):
    auth_id = "twitter_%s" % response["user_id"]
    user_db = model.User.get_by("auth_ids", auth_id)
    return user_db or auth.create_or_get_user_db(
        auth_id=auth_id, name=response["screen_name"], username=response["screen_name"], verified=True
    )