2013-04-23 18:51:17 +02:00
|
|
|
from __future__ import absolute_import
|
2015-11-01 17:11:06 +01:00
|
|
|
from __future__ import print_function
|
2013-04-23 18:51:17 +02:00
|
|
|
|
2012-10-10 20:42:04 +02:00
|
|
|
from django.core.management.base import BaseCommand
|
2013-07-29 23:03:31 +02:00
|
|
|
from zerver.lib.initial_password import initial_password
|
|
|
|
from zerver.models import get_user_profile_by_email
|
2012-10-10 20:42:04 +02:00
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2012-10-12 17:10:59 +02:00
|
|
|
help = "Print the initial password and API key for accounts as created by populate_db"
|
|
|
|
|
|
|
|
fmt = '%-30s %-16s %-32s'
|
2012-10-10 20:42:04 +02:00
|
|
|
|
2015-08-21 02:10:41 +02:00
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument('emails', metavar='<email>', type=str, nargs='*',
|
|
|
|
help="email of user to show password and API key for")
|
|
|
|
|
2012-10-10 20:42:04 +02:00
|
|
|
def handle(self, *args, **options):
|
2015-11-01 17:11:06 +01:00
|
|
|
print(self.fmt % ('email', 'password', 'API key'))
|
2015-08-21 02:10:41 +02:00
|
|
|
for email in options['emails']:
|
2012-10-10 20:42:04 +02:00
|
|
|
if '@' not in email:
|
2015-11-01 17:11:06 +01:00
|
|
|
print('ERROR: %s does not look like an email address' % (email,))
|
2012-10-10 20:42:04 +02:00
|
|
|
continue
|
2015-11-01 17:11:06 +01:00
|
|
|
print(self.fmt % (email, initial_password(email), get_user_profile_by_email(email).api_key))
|