Ejemplo n.º 1
0
def getSocialUrlByUser(user):
    try:
        socialUser = DjangoUserMixin.get_social_auth_for_user(user)[0]
        if socialUser.provider == "vk-oauth2":
            return "vk.com/id{}".format(socialUser.uid)
            # TODO: Add facebook
    except:
        return None
Ejemplo n.º 2
0
def update_user_details(hacker_id, user):
    social_auth = DjangoUserMixin.get_social_auth_for_user(user)[0]
    backend = social_auth.get_backend_instance()
    social_auth.refresh_token(DjangoStrategy())
    url = backend.HACKER_SCHOOL_ROOT + '/api/v1/people/%s?' % hacker_id + urlencode({
        'access_token': social_auth.extra_data['access_token']
    })

    try:
        response = backend.request(url, method='GET')
        hacker_data = backend.get_user_details(response.json())
        create_or_update_hacker(None, hacker_data, None, User.objects.get(id=hacker_id))

    except Exception:
        # It's not very bad, if we are not able to update the userdata... we
        # silently ignore it.
        pass
Ejemplo n.º 3
0
def update_user_details(hacker_id, user):
    social_auth = DjangoUserMixin.get_social_auth_for_user(user)[0]
    backend = social_auth.get_backend_instance()
    social_auth.refresh_token(DjangoStrategy())
    url = backend.HACKER_SCHOOL_ROOT + '/api/v1/people/%s?' % hacker_id + urlencode(
        {'access_token': social_auth.extra_data['access_token']})

    try:
        response = backend.request(url, method='GET')
        hacker_data = backend.get_user_details(response.json())
        create_or_update_hacker(None, hacker_data, None,
                                User.objects.get(id=hacker_id))

    except Exception:
        # It's not very bad, if we are not able to update the userdata... we
        # silently ignore it.
        pass