def oauth_callback(provider): if not current_user.is_anonymous: return redirect(url_for('index')) oauth = OAuthSignIn.get_provider(provider) social_id, username, name, image = oauth.callback() if social_id is None: flash('Authentication failed.') return redirect(url_for('index')) user = models.User.query.filter_by(social_id=social_id).first() if not user: user = models.User(social_id=social_id, username=username, name=name, imageurl=image) db.session.add(user) db.session.commit() login_user(user, True) return redirect(url_for('admin.retrievepage'))
def oauth_authorize(provider): if not current_user.is_anonymous: return redirect(url_for('index')) oauth = OAuthSignIn.get_provider(provider) return oauth.authorize()