add some commands to list and wipe users to remove spammers

master
lza_menace 3 years ago
parent b34cf05497
commit 8da92e6919

@ -3,7 +3,7 @@ from flask import Blueprint, url_for
import wowstash.models
from wowstash.library.docker import docker
from wowstash.models import User, PasswordReset
from wowstash.models import User, PasswordReset, Event
from wowstash.factory import db, bcrypt
@ -25,6 +25,29 @@ def reset_wallet(user_id):
def init():
db.create_all()
@bp.cli.command('list_users')
def list_users():
users = User.query.all()
for i in users:
print(f'{i.id} - {i.email}')
@bp.cli.command('wipe_user')
@click.argument('user_id')
def wipe_user(user_id):
user = User.query.get(user_id)
if user:
events = Event.query.filter(Event.user == user.id)
for i in events:
print(f'[+] Deleting event {i.id} for user {user.id}')
db.session.delete(i)
print(f'[+] Deleting user {user.id}')
db.session.delete(user)
db.session.commit()
return True
else:
print('That user id does not exist')
return False
@bp.cli.command('reset_password')
@click.argument('user_email')
@click.argument('duration')

Loading…
Cancel
Save