mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Adding forgot password management command.
This commit is contained in:
parent
6063224c1b
commit
c2653fa869
3 changed files with 28 additions and 0 deletions
0
apps/profile/management/__init__.py
Normal file
0
apps/profile/management/__init__.py
Normal file
0
apps/profile/management/commands/__init__.py
Normal file
0
apps/profile/management/commands/__init__.py
Normal file
28
apps/profile/management/commands/fp.py
Normal file
28
apps/profile/management/commands/fp.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from django.contrib.auth.models import User
|
||||
from optparse import make_option
|
||||
|
||||
class Command(BaseCommand):
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option("-u", "--username", dest="username", nargs=1, help="Specify user id or username"),
|
||||
make_option("-e", "--email", dest="email", nargs=1, help="Specify email if it doesn't exist"),
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
username = options['username']
|
||||
user = None
|
||||
try:
|
||||
user = User.objects.get(username__icontains=username)
|
||||
except User.MultipleObjectsFound:
|
||||
user = User.objects.get(username__iexact=username)
|
||||
except User.DoesNotExist:
|
||||
user = User.objects.get(email__icontains=username)
|
||||
except User.DoesNotExist:
|
||||
print " ---> No user/email found at: %s" % username
|
||||
|
||||
if user:
|
||||
email = options.get("email") or user.email
|
||||
user.profile.send_forgot_password_email(email)
|
||||
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue