[Enhance] Self account delete

- Add support for users destroy their own accounts
This commit is contained in:
Lost-MSth
2024-02-25 17:28:54 +08:00
parent b3bf55407f
commit e206247c09
8 changed files with 125 additions and 36 deletions

View File

@@ -2,7 +2,7 @@ import os
import time
from core.init import FileChecker
from core.operation import RefreshAllScoreRating, RefreshSongFileCache, SaveUpdateScore, UnlockUserItem
from core.operation import RefreshAllScoreRating, RefreshSongFileCache, SaveUpdateScore, UnlockUserItem, DeleteUserScore
from core.rank import RankList
from core.sql import Connect
from core.user import User
@@ -1366,7 +1366,10 @@ def delete_user_score():
user_id = c.fetchone()
if user_id:
user_id = user_id[0]
web.system.clear_user_score(c, user_id)
c.execute('''update user set rating_ptt=0, song_id='', difficulty=0, score=0, shiny_perfect_count=0, perfect_count=0, near_count=0, miss_count=0, health=0, time_played=0, rating=0, world_rank_score=0 where user_id=:a''', {
'a': user_id})
c.connection.commit()
DeleteUserScore().set_params(user_id=user_id).run()
flash("用户成绩删除成功 Successfully delete the user's scores.")
else:

View File

@@ -261,12 +261,3 @@ def ban_one_user(c, user_id):
{'a': user_id})
c.execute('''delete from login where user_id=:a''', {'a': user_id})
return
def clear_user_score(c, user_id):
# 清除用户所有成绩包括best_score和recent30以及recent数据但不包括云端存档
c.execute('''update user set rating_ptt=0, song_id='', difficulty=0, score=0, shiny_perfect_count=0, perfect_count=0, near_count=0, miss_count=0, health=0, time_played=0, rating=0, world_rank_score=0 where user_id=:a''',
{'a': user_id})
c.execute('''delete from best_score where user_id=:a''', {'a': user_id})
c.execute('''delete from recent30 where user_id=:a''', {'a': user_id})
return