Skip to content

Commit

Permalink
Delete Account Execution
Browse files Browse the repository at this point in the history
  • Loading branch information
WeepingDogel committed Jan 17, 2023
1 parent b358444 commit be53792
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions flaskr/auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Authorization

import functools,time,os,uuid,cv2
import functools,time,os,uuid,cv2, shutil
from flaskr.db import get_db
from flask import(
Blueprint,
Expand Down Expand Up @@ -118,4 +118,35 @@ def load_logged_in_user():
g.user = get_db().execute(
'SELECT * FROM USERS WHERE UserName = ?', (user_id,)
).fetchone()



@bp.route('/deleteAccount')
def deleteAccount():
if 'username' not in session:
return 'error!', 500
else:
username = session['username']
db = get_db()
db.execute(
'DELETE FROM USERS WHERE UserName =?',
(username,)
)
db.commit()
db.execute(
'DELETE FROM IMAGES WHERE User = ?',
(username,)
)
db.commit()
db.execute(
'DELETE FROM COMMENTS WHERE User = ?',
(username,)
)
db.commit()
db.execute(
'DELETE FROM ImagesLikedByUser WHERE User = ?',
(username,)
)
db.commit()
shutil.rmtree((current_app.config['USERFILE_DIR'] + '/' + username))

return redirect(url_for('auth.logout'))

0 comments on commit be53792

Please sign in to comment.