Create user command for mangling users (#98)
* Create user command for mangling users * remove 'identity' arguement to CLI command * fix typo
This commit is contained in:
parent
aa15b13782
commit
98dce6c5ea
|
@ -60,11 +60,14 @@ LINKEDIN_CLIENT_SECRET = env.str("LINKEDIN_CLIENT_SECRET")
|
|||
BLOCKCHAIN_REST_API_URL = env.str("BLOCKCHAIN_REST_API_URL")
|
||||
BLOCKCHAIN_API_SECRET = env.str("BLOCKCHAIN_API_SECRET")
|
||||
|
||||
STAGING_PASSWORD = env.str("STAGING_PASSWORD")
|
||||
|
||||
EXPLORER_URL = env.str("EXPLORER_URL", default="https://chain.so/tx/ZECTEST/<txid>")
|
||||
|
||||
PROPOSAL_STAKING_AMOUNT = Decimal(env.str("PROPOSAL_STAKING_AMOUNT"))
|
||||
PROPOSAL_TARGET_MAX = Decimal(env.str("PROPOSAL_TARGET_MAX"))
|
||||
|
||||
|
||||
UI = {
|
||||
'NAME': 'ZF Grants',
|
||||
'PRIMARY': '#CF8A00',
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import click
|
||||
from flask.cli import with_appcontext
|
||||
|
||||
from .models import User, db
|
||||
from .models import User, db, SocialMedia
|
||||
from grant.task.models import Task
|
||||
from grant.settings import STAGING_PASSWORD
|
||||
|
||||
|
||||
# @click.command()
|
||||
|
@ -23,7 +25,6 @@ from .models import User, db
|
|||
# 'account address, or email address of an ' \
|
||||
# 'existing user.')
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.argument('identity')
|
||||
@with_appcontext
|
||||
|
@ -43,3 +44,28 @@ def set_admin(identity):
|
|||
raise click.BadParameter('''Invalid user identity. Must be a userid,
|
||||
'account address, or email address of an
|
||||
'existing user.''')
|
||||
|
||||
|
||||
@click.command()
|
||||
@with_appcontext
|
||||
def mangle_users():
|
||||
if STAGING_PASSWORD:
|
||||
print("Mangling all users")
|
||||
for i, user in enumerate(User.query.all()):
|
||||
user.email_address = "random" + str(i) + "@grant.io"
|
||||
user.password = STAGING_PASSWORD
|
||||
# DELETE TOTP SECRET
|
||||
user.totp_secret = None
|
||||
# DELETE BACKUP CODES
|
||||
user.backup_codes = None
|
||||
db.session.add(user)
|
||||
|
||||
# DELETE ALL TASKS
|
||||
for task in Task.query.all():
|
||||
db.session.delete(task)
|
||||
|
||||
# REMOVE ALL SOCIAL MEDIA
|
||||
for social in SocialMedia.query.all():
|
||||
db.session.delete(social)
|
||||
|
||||
db.session.commit()
|
||||
|
|
Loading…
Reference in New Issue