adds delete account function

This commit is contained in:
Raphael Maenle 2020-05-22 10:47:28 +02:00
parent cf9c4f0e85
commit 98a78f2102
4 changed files with 19 additions and 6 deletions

BIN
app.db

Binary file not shown.

Binary file not shown.

View File

@ -93,6 +93,13 @@ def verifyResponse():
def get_google_provider_cfg(): def get_google_provider_cfg():
return requests.get(GOOGLE_DISCOVERY_URL).json() 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: class Calendar:
def __init__(self, name, calendarId, toggle='False', color="#000000"): def __init__(self, name, calendarId, toggle='False', color="#000000"):
self.name = name self.name = name

View File

@ -100,13 +100,19 @@ def register():
return redirect(url_for('emaillogin')) return redirect(url_for('emaillogin'))
return flask.render_template('register.html', title='Register', form=form) return flask.render_template('register.html', title='Register', form=form)
@app.route("/test") @app.route("/delete_account")
def testAPI(): def deleteAccount():
if current_user.is_authenticated: if not current_user.is_authenticated:
google.updateCalendars() return redirect(url_for('account'))
return redirect('/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") @app.route("/login/google")
def googlelogin(): def googlelogin():