This commit is contained in:
beabigegg
2025-08-28 08:59:46 +08:00
parent b9557250a4
commit 4f7f46b07a
42 changed files with 4992 additions and 494 deletions

37
update_admin.py Normal file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env python3
"""
更新使用者權限為管理員的腳本
"""
from models import db, User
from app import app
def update_user_to_admin(username):
"""將指定使用者設為管理員權限"""
with app.app_context():
user = User.query.filter_by(username=username).first()
if user:
print(f'找到使用者: {user.username}')
print(f'當前權限: {user.role}')
if user.role != 'admin':
user.role = 'admin'
db.session.commit()
print(f'權限已更新為: {user.role}')
else:
print('使用者已經是管理員權限')
return True
else:
print(f'使用者 {username} 不存在')
return False
if __name__ == "__main__":
username = 'ymirliu@panjit.com.tw'
print(f"正在更新使用者 {username} 的權限...")
success = update_user_to_admin(username)
if success:
print("\n管理員權限設定完成!")
else:
print("\n請先使用該帳號登入一次以建立使用者記錄")