Last active
April 24, 2019 19:20
-
-
Save merqurio/2f8f55987ccc224e2342 to your computer and use it in GitHub Desktop.
Flask login using Google App Engine User Service
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
# import dependencies | |
from functools import wraps | |
from google.appengine.api import users | |
from flask import redirect, request | |
USERS = ["any@gmail.com", "any@googleapps.com"] | |
#Set's the login to Google Users Service | |
def login_required(func): | |
@wraps(func) | |
def decorated_view(*args, **kwargs): | |
if not users.get_current_user(): | |
return redirect(users.create_login_url(request.url)) | |
else: | |
user = users.get_current_user() | |
if user.email() in USERS: | |
return func(*args, **kwargs) | |
else: | |
return 'Trampak iten ?' | |
return decorated_view |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment