Fix not deleting old user issue

This commit is contained in:
Aaron Lee 2021-11-01 19:14:32 +08:00
parent 17c722c9c7
commit a355887755
2 changed files with 1 additions and 3 deletions

3
app.py
View file

@ -69,7 +69,6 @@ def index():
@app.route('/select', methods=['GET', 'POST']) @app.route('/select', methods=['GET', 'POST'])
def selSubUser(): def selSubUser():
if check_login_status(): if check_login_status():
print(session)
session.clear() session.clear()
flash("Timeout. 遇時,請重新登入") flash("Timeout. 遇時,請重新登入")
return redirect('/') return redirect('/')
@ -130,7 +129,6 @@ def chgPassword():
old['token'] = oldUsr['idToken'] old['token'] = oldUsr['idToken']
data = db.child("Users").child( data = db.child("Users").child(
oldUsr['localId']).get(oldUsr['idToken']).val() oldUsr['localId']).get(oldUsr['idToken']).val()
print("data:", data, flush=True)
auth.delete_user_account(oldUsr['idToken']) auth.delete_user_account(oldUsr['idToken'])
delUser = True delUser = True
@ -139,6 +137,7 @@ def chgPassword():
request.form['new_username'], request.form['new_password']) request.form['new_username'], request.form['new_password'])
db.child("Users").child(newUsr['localId']).set( db.child("Users").child(newUsr['localId']).set(
data, newUsr['idToken']) data, newUsr['idToken'])
db.child("Users").child(oldUsr['localId']).remove(oldUsr['idToken'])
session.clear() session.clear()
flash( flash(
'修改密碼成功,請重新登入<br>Password changed successfully. Please login again.') '修改密碼成功,請重新登入<br>Password changed successfully. Please login again.')

View file

@ -105,7 +105,6 @@ def upload_gp_classes():
csv_dict.columns[i+1]: tmp_csv[j], csv_dict.columns[i+1]: tmp_csv[j],
"type": 'group' "type": 'group'
}, session['token']) }, session['token'])
accs.remove(allUsers[key]['origUsername'])
os.remove(filepath) os.remove(filepath)
except Exception as e: except Exception as e:
os.remove(filepath) os.remove(filepath)