diff --git a/app.db b/app.db index f95e63b..a7d11d0 100644 Binary files a/app.db and b/app.db differ diff --git a/app.db.old b/app.db.old deleted file mode 100644 index 73e7dab..0000000 Binary files a/app.db.old and /dev/null differ diff --git a/server/googleHandler.py b/server/googleHandler.py index 888acd6..aca646e 100644 --- a/server/googleHandler.py +++ b/server/googleHandler.py @@ -93,6 +93,13 @@ def verifyResponse(): def get_google_provider_cfg(): return requests.get(GOOGLE_DISCOVERY_URL).json() +def deleteAccount(user): + result = requests.post('https://oauth2.googleapis.com/revoke', + params={'token': user.get('token')}, + headers = {'content-type': 'applixation/x-www-form-urlencoded'}) + print(result, flush=True) + return + class Calendar: def __init__(self, name, calendarId, toggle='False', color="#000000"): self.name = name diff --git a/server/routes.py b/server/routes.py index 10e6750..c94f8ec 100644 --- a/server/routes.py +++ b/server/routes.py @@ -100,13 +100,19 @@ def register(): return redirect(url_for('emaillogin')) return flask.render_template('register.html', title='Register', form=form) -@app.route("/test") -def testAPI(): - if current_user.is_authenticated: - google.updateCalendars() - return redirect('/account') - +@app.route("/delete_account") +def deleteAccount(): + if not current_user.is_authenticated: + return redirect(url_for('account')) + print(current_user.getGoogleCredentials(), flush=True) + google.deleteAccount(current_user.getGoogleCredentials()) + + user = db.session.query(User).filter(User.id==current_user.id).first() + logout_user() + db.session.delete(user) + db.session.commit() + return redirect(url_for('account')) @app.route("/login/google") def googlelogin():