#18897: add the password as 2nd argument to changepassword command
--------------------------------------------+--------------------
     Reporter:  maduma@…                    |      Owner:  nobody
         Type:  New feature                 |     Status:  new
    Component:  Core (Management commands)  |    Version:  1.4
     Severity:  Normal                      |   Keywords:
 Triage Stage:  Unreviewed                  |  Has patch:  1
Easy pickings:  0                           |      UI/UX:  0
--------------------------------------------+--------------------
 Added the possibility to pass the username and the password to
 'changepassword' command.
 This was the only cmd that need user input during initial setup

 {{{
 !sh
 # rm sqlite3.db; python manage.py syncdb --noinput; \
 python manage.py createsuperuser --noinput --username=maduma
 [email protected]; \
 python manage.py changepassword maduma not4u

 # python manage.py changepassword maduma not4u
 Changing password for user 'maduma'
 Password changed successfully for user 'maduma'

 # diff changepassword-old.py changepassword.py
 25,26c25,26
 <         if len(args) > 1:
 <             raise CommandError("need exactly one or zero arguments for
 username")
 ---
 >         if len(args) > 2:
 >             raise CommandError("need exactly one, two or zero arguments
 for username and password")
 28c28,30
 <         if args:
 ---
 >         if len(args) == 2:
 >             username, p1 = args
 >         elif len(args) == 1:
 40,48c42,53
 <         MAX_TRIES = 3
 <         count = 0
 <         p1, p2 = 1, 2  # To make them initially mismatch.
 <         while p1 != p2 and count < MAX_TRIES:
 <             p1 = self._get_pass()
 <             p2 = self._get_pass("Password (again): ")
 <             if p1 != p2:
 <                 self.stdout.write("Passwords do not match. Please try
 again.\n")
 <                 count = count + 1
 ---
 >         if not p1:
 >             MAX_TRIES = 3
 >             count = 0
 >             p1, p2 = 1, 2  # To make them initially mismatch.
 >             while p1 != p2 and count < MAX_TRIES:
 >                 p1 = self._get_pass()
 >                 p2 = self._get_pass("Password (again): ")
 >                 if p1 != p2:
 >                     self.stdout.write("Passwords do not match. Please
 try again.\n")
 >                     count = count + 1
 >             if count == MAX_TRIES:
 >                 raise CommandError("Aborting password change for user
 '%s' after %s attempts" % (username, count))
 50,52d54
 <         if count == MAX_TRIES:
 <             raise CommandError("Aborting password change for user '%s'
 after %s attempts" % (username, count))
 <
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18897>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to