Ejemplo n.º 1
0
def login(server_name):
    if server_name == "Facebook":
        callback = url_for('facebook_authorized',
                           next=request.args.get('next') or request.referrer
                           or None,
                           _external=True)
        return facebook.authorize(callback=callback)

    return google.authorize(callback=url_for('g_authorized', _external=True))
Ejemplo n.º 2
0
def facebook_callback(resp):

    next_url = request.args.get('next') or url_for('index')

    if resp is None or 'access_token' not in resp:
        flash('You denied the login')
        return redirect(next_url)

    session['fb_access_token'] = (resp['access_token'], '')
    
    remember_me = False
    
    if 'remember_me' in session:
        remember_me = session['remember_me']
        session.pop('remember_me', None)

    fb_user = facebook.get('/me')
    fb_id = me.data['id']
    fb_email = me.data['email']
    
    if fb_user.data['username']:
        fb_username = fb_user.data['username']
    else:
        fb_username = fb_user.data['name']

    user = dq.find(User, ['facebook_id'], [str(fb_id)]).first()

    #for connecting user's acc with facebook acc
    if g.user is not None and g.user.is_authenticated():
        if user is None:
            dq.update(g.user, ['facebook_id'], [str(fb_id)])
            flash('You are now linked with %s' % fb_username)
        else:
            flash('Your fb account has been linked previously')

        return redirect(url_for('settings'))

    #for new login

    if user is None:
        u = dq.find(User, ['email'], [str(fb_email)]).first()
        if u:
            login_user(u, remember = remember_me)
            return facebook.authorize(callback=url_for('facebook_callback',
                    next=request.args.get('next') or request.referrer or None,
                    _external=True))
        else:
            dq.init_user(fb_username, fb_email, ROLE_USER, None, None, str(fb_id), None, None)

    login_user(user, remember = remember_me)

    flash('You are now logged in as %s' % user.nickname)
    return redirect(url_for('index'))
Ejemplo n.º 3
0
def login():
    """Redirects user to FB auth. process if new user or else will
    automaticaly log user in.

    """
    callback = url_for(
        'facebook_authorized',
        next=request.args.get('next')
            or request.referrer 
            or None,
        _external=True
    )
    return facebook.authorize(callback=callback)
Ejemplo n.º 4
0
def login(server_name):
    if server_name == "Facebook":
        callback = url_for(
            'facebook_authorized',
            next=request.args.get('next')
                or request.referrer 
                or None,
            _external=True
        )
        return facebook.authorize(callback=callback)

    return google.authorize(
        callback=url_for('g_authorized', _external=True)
    )
Ejemplo n.º 5
0
def login():
    if g.user is not None and g.user.is_authenticated():
        return redirect(url_for('index'))
    form = LoginForm()
    for e in request.form:
        print e
    if form.validate_on_submit():
        if "facebook_login" in request.form:
            print request.form
            return facebook.authorize(callback=url_for(
                'facebook_authorized',
                next=request.args.get('next') or request.referrer or None,
                _external=True))
    return render_template('login.html',
                           titile='Sign In',
                           form=form,
                           providers=app.config['OPENID_PROVIDERS'])
Ejemplo n.º 6
0
def facebook_login():
    return facebook.authorize(callback=url_for('facebook_authorized',
        next=request.args.get('next'), _external=True))
Ejemplo n.º 7
0
def facebook_login():
    return facebook.authorize(
        callback=url_for(
            "idleg.facebook_authorized", next=request.args.get("next") or request.referrer or None, _external=True
        )
    )
Ejemplo n.º 8
0
def login_fa():
	 return facebook.authorize(callback=url_for('facebook_authorized', next=request.args.get('next') or request.referrer or None, _external=True))
Ejemplo n.º 9
0
def facebook_login():
    return facebook.authorize(callback=url_for('facebook_authorized',
        next=request.args.get('next'), _external=True))
Ejemplo n.º 10
0
def login():
    return facebook.authorize(callback=url_for('facebook_authorized',
                                               next=request.args.get('next')
                                               or request.referrer or None,
                                               _external=True))
Ejemplo n.º 11
0
def login_facebook():
    return facebook.authorize(callback="http://localhost:5000/")
Ejemplo n.º 12
0
def login():
    callback = url_for('authorize_facebook', _external=True)
    return facebook.authorize(callback=callback)