Ejemplo n.º 1
0
def update(id):
    account = object_or_404(Account.by_id(id))
    authz.require(account.id == request.account.id)
    data = request_data()
    account = accounts.save(data, account=account)
    db.session.commit()
    return jsonify(account)
Ejemplo n.º 2
0
def update(id):
    account = object_or_404(Account.by_id(id))
    authz.require(account.id==request.account.id)
    data = request_data()
    entity = accounts.save(data, account=account)
    db.session.commit()
    return jsonify(accounts.to_rest(account))
Ejemplo n.º 3
0
def facebook_authorized(resp):
    next_url = session.get('next_url', '/')
    if resp is None or 'access_token' not in resp:
        return redirect(next_url)
    session['facebook_token'] = (resp.get('access_token'), '')
    data = PROVIDERS.get('facebook').get('/me').data
    account = Account.by_facebook_id(data.get('id'))
    data_ = {
        'full_name': data.get('name'),
        'login': data.get('username'),
        'email': data.get('email'),
        'facebook_id': data.get('id')
    }
    account = accounts.save(data_, account=account)
    db.session.commit()
    session['id'] = account.id
    return redirect(next_url)
Ejemplo n.º 4
0
def facebook_authorized(resp):
    next_url = session.get('next_url', '/')
    if resp is None or not 'access_token' in resp:
        return redirect(next_url)
    session['facebook_token'] = (resp.get('access_token'), '')
    data = facebook.get('/me').data
    account = Account.by_facebook_id(data.get('id'))
    data_ = {
        'full_name': data.get('name'),
        'login': data.get('username'),
        'email': data.get('email'),
        'facebook_id': data.get('id')
    }
    account = accounts.save(data_, account=account)
    db.session.commit()
    session['id'] = account.id
    return redirect(next_url)
Ejemplo n.º 5
0
def twitter_authorized(resp):
    next_url = session.get('next_url', '/')
    if resp is None or 'oauth_token' not in resp:
        return redirect(next_url)
    session['twitter_token'] = (resp['oauth_token'],
                                resp['oauth_token_secret'])
    provider = PROVIDERS.get('twitter')
    res = provider.get('users/show.json?user_id=%s' % resp.get('user_id'))
    account = Account.by_twitter_id(res.data.get('id'))
    data_ = {
        'full_name': res.data.get('name'),
        'login': res.data.get('screen_name'),
        'twitter_id': res.data.get('id')
    }
    account = accounts.save(data_, account=account)
    db.session.commit()
    session['id'] = account.id
    return redirect(next_url)
Ejemplo n.º 6
0
def twitter_authorized(resp):
    next_url = session.get('next_url', '/')
    if resp is None or not 'oauth_token' in resp:
        return redirect(next_url)

    session['twitter_token'] = (resp['oauth_token'],
                                resp['oauth_token_secret'])
    res = twitter.get('users/show.json?user_id=%s' % resp.get('user_id'))
    account = Account.by_twitter_id(res.data.get('id'))
    data_ = {
        'full_name': res.data.get('name'),
        'login': res.data.get('screen_name'),
        'twitter_id': res.data.get('id')
    }
    account = accounts.save(data_, account=account)
    db.session.commit()
    session['id'] = account.id
    return redirect(next_url)
Ejemplo n.º 7
0
def github_authorized(resp):
    next_url = session.get('next_url', '/')
    if resp is None or 'access_token' not in resp:
        return redirect(next_url)
    access_token = resp['access_token']
    session['access_token'] = access_token, ''
    url = 'https://api.github.com/user?access_token=%s'
    res = requests.get(url % access_token, verify=False)
    data = res.json()
    account = Account.by_github_id(data.get('id'))
    data_ = {
        'full_name': data.get('name'),
        'login': data.get('login'),
        'email': data.get('email'),
        'github_id': data.get('id')
    }
    account = accounts.save(data_, account=account)
    db.session.commit()
    session['id'] = account.id
    return redirect(next_url)
Ejemplo n.º 8
0
def github_authorized(resp):
    next_url = session.get('next_url', '/')
    if resp is None or 'access_token' not in resp:
        return redirect(next_url)
    access_token = resp['access_token']
    session['access_token'] = access_token, ''
    url = 'https://api.github.com/user?access_token=%s'
    res = requests.get(url % access_token, verify=False)
    data = res.json()
    account = Account.by_github_id(data.get('id'))
    data_ = {
        'full_name': data.get('name'),
        'login': data.get('login'),
        'email': data.get('email'),
        'github_id': data.get('id')
    }
    account = accounts.save(data_, account=account)
    db.session.commit()
    session['id'] = account.id
    return redirect(next_url)