Created
March 30, 2019 18:19
-
-
Save altendky/8922824df4f8c633a85bf60fa23da2e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from . import google | |
dispatch = { | |
'google': google.validate | |
}[platform](token) | |
def get_profile_for_token(client_ids, platform, token): | |
if platform == 'google' and platform in client_ids: | |
return google.validate(client_ids[platform], token) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/login', methods=['POST']) | |
def login(): | |
data = request.get_json() | |
try: | |
platform = data['platform'] | |
token = data['token'] | |
except IndexError: | |
return Response(status=400) | |
profile = oauth.get_profile_for_token(fbf.config.config['oauth_ids'], platform, token) | |
if profile: | |
user_id = profile['email'] | |
user = db.Query(fbf.db.User).filter_by(user_id=user_id).first() | |
if not user: | |
new_user = fbf.db.User(user_id=user_id) | |
db.session.add(new_user) | |
db.session.commit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment