From 517266b805dd1300197caa3b4ef910feba159695 Mon Sep 17 00:00:00 2001 From: Hailey Date: Sun, 6 Oct 2019 16:30:47 -0700 Subject: [PATCH] Oughta work It oughta work, this is a different way of pulling the code. --- app-ajax.py | 5 ++++- appdb.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app-ajax.py b/app-ajax.py index 82e01fe..0b263f7 100755 --- a/app-ajax.py +++ b/app-ajax.py @@ -40,7 +40,10 @@ def index(): if indbRes: pprint.pprint(indbRes) refreshtoken = google_auth.getRefreshToken() - userid = appdb.getUserIdFromRT(refreshtoken) + if not refreshtoken: + return "Error with your refresh token" + + userid = appdb.getUserIDfromGoogleID(user_info['id']) if not userid: return 'You are not currently logged in.' diff --git a/appdb.py b/appdb.py index 2ec608d..b58e66a 100755 --- a/appdb.py +++ b/appdb.py @@ -72,6 +72,17 @@ def getUserIdFromRT(refreshtoken): return False return data[0] +def getUserIDfromGoogleID(google_id): + #This pulls an UserID from a Google ID + db = pymysql.connect(host=sqlhost, user=sqluser, passwd=sqlpass, db=sqldb) + cur = db.cursor() + cur.execute("SELECT id FROM account WHERE google_id=%s",(google_id)) + data = cur.fetchone() + db.close() + if not data: + return False + return data[0] + def getAccountbyDID(did): #This function pulls the account id for the DID in the query. db = pymysql.connect(host=sqlhost, user=sqluser, passwd=sqlpass, db=sqldb)