-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.py
More file actions
27 lines (21 loc) · 834 Bytes
/
user.py
File metadata and controls
27 lines (21 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import flask
#original
from flask import Blueprint, request, current_app, make_response
from google.cloud import datastore
import json
import constants
from google.oauth2 import id_token
from google.auth.transport import requests
from helper import return_json
encoding = 'utf-8'
client = datastore.Client()
bp = Blueprint('users', __name__, url_prefix='/users')
def users_post(userID, firstName, lastName):
new_user = datastore.entity.Entity(key=client.key(constants.users))
new_user.update({"userID": userID, "firstName": firstName, "lastName": lastName})
client.put(new_user)
def user_exist(id):
query = client.query(kind=constants.users)
query.add_filter("userID", "=", id) #filter the owner according to sub in jwt
results = list(query.fetch())
return results