Ejemplo n.º 1
0
def oauth_callback(provider, user=None):
    if not current_user.is_anonymous():
        return redirect(url_for('index'))
    oauth = OAuthSignIn.get_provider(provider)
    social_id, username, email = oauth.callback()
    if social_id is None:
        flash('Authentication failed.')
        return redirect(url_for('frontend.index'))
    # update to foreign key later
    # user = User.query.filter_by(social_id=social_id).first()
    if not user:
        user = User().create(nickname=username, email=email)
        social_id = UsersSocialAccount().create(social_id=social_id, provider=provider)
        user.social_ids.append(social_id)
        db.session.commit()
    login_user(user, True)
    return redirect(url_for('user.index'))
Ejemplo n.º 2
0
def oauth_callback(provider, user=None):
    if not current_user.is_anonymous():
        return redirect(url_for('index'))
    oauth = OAuthSignIn.get_provider(provider)
    social_id, username, email = oauth.callback()
    if social_id is None:
        flash('Authentication failed.')
        return redirect(url_for('frontend.index'))
    # update to foreign key later
    # user = User.query.filter_by(social_id=social_id).first()
    if not user:
        user = User().create(nickname=username, email=email)
        social_id = UsersSocialAccount().create(social_id=social_id,
                                                provider=provider)
        user.social_ids.append(social_id)
        db.session.commit()
    login_user(user, True)
    return redirect(url_for('user.index'))
Ejemplo n.º 3
0
def oauth_authorize(provider):
    if not current_user.is_anonymous():
        return redirect(url_for('user.index'))
    oauth = OAuthSignIn.get_provider(provider)
    return oauth.authorize()
Ejemplo n.º 4
0
def oauth_authorize(provider):
    if not current_user.is_anonymous():
        return redirect(url_for('user.index'))
    oauth = OAuthSignIn.get_provider(provider)
    return oauth.authorize()