Opened 16 years ago

Closed 14 years ago

#6273 closed (fixed)

Support for passwd-like password changing

Reported by: Ludvig Ericson Owned by: Justin Lilly
Component: Core (Management commands) Version: dev
Severity: Keywords:
Cc: justinlilly@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I wrote a short command handler for management to change the password of the current user, or a given user, just like passwd.

Attachments (4)

django-passwd.diff (1.4 KB ) - added by Ludvig Ericson 16 years ago.
django_auth_passwd_command.diff (6.7 KB ) - added by Ludvig Ericson 16 years ago.
6273_django_auth_passwd_command_r2.diff (1.5 KB ) - added by Justin Lilly 15 years ago.
Applies cleanly to r9478 -- Removed all changes except passwd.py which works.
6273_change_password_auth_command.diff (2.3 KB ) - added by Justin Lilly 15 years ago.
Now with docs and renamed to change_password

Download all attachments as: .zip

Change History (18)

by Ludvig Ericson, 16 years ago

Attachment: django-passwd.diff added

comment:1 by Adrian Holovaty, 16 years ago

Owner: changed from nobody to Adrian Holovaty
Patch needs improvement: set
Status: newassigned

This is a good idea, but a key improvement needs to be made before we can check it in. Because Django's auth system is technically a contrib app, this command should live in the django/contrib/auth directory. The advantages of this are that it won't clutter the django-admin.py command namespace if the auth app isn't installed, and it keeps all of the auth code together in the same subpackage.

Could you rework the patch to do this? Here's some documentation on how applications can specify custom django-admin.py actions: http://www.djangoproject.com/documentation/django-admin/#customized-actions

comment:2 by Adrian Holovaty, 16 years ago

Owner: changed from Adrian Holovaty to nobody
Status: assignednew

Ack, I didn't mean to accept the ticket -- hopefully toxik will be able to code up the patch.

comment:3 by Simon Greenhill <dev@…>, 16 years ago

Triage Stage: UnreviewedAccepted

by Ludvig Ericson, 16 years ago

comment:4 by Ludvig Ericson, 16 years ago

Okay, sorry for the delay, but I fixed it. Works for me, but I had to make management.py a package, so I don't know if that has any side-effects. (Moved it to ./management/__init__.py, should be fine I suppose.)

Also note that you want to delete the old management.py file since I doubt the patch will do that.

comment:5 by Ludvig Ericson, 16 years ago

Oh and I changed the command a lil' bit, now it aborts if any of the two inputs are empty rather than if any are empty after both have been answered.

Also I'd like to post this svn st so as to clarify what I meant:

D      django/contrib/auth/management.py
A      django/contrib/auth/management
A      django/contrib/auth/management/commands
A      django/contrib/auth/management/commands/__init__.py
A      django/contrib/auth/management/commands/passwd.py
A      django/contrib/auth/management/__init__.py

by Justin Lilly, 15 years ago

Applies cleanly to r9478 -- Removed all changes except passwd.py which works.

comment:6 by Justin Lilly, 15 years ago

Cc: justinlilly@… added

comment:7 by Justin Lilly, 15 years ago

This functionality is available via django-command-extensions http://code.google.com/p/django-command-extensions/ Not sure if it should be wontfix'd as its available as a 3rd party app, especially since adrian was in favor. That being said, adrian was in favor before django-command-extensions existed. Hopefully someone with a better grasp on this stuff can decide?

comment:8 by Ludvig Ericson, 15 years ago

Well, it's in django-command-extensions because I put it there. :-)

I think something like this should be available so that you don't have to force system administrators to either update a user's password using a Python shell or by means of the admin.

As an aside, would you (justinlilly) care to maintain this one? It'd be nice as I don't have the time over that I used to, what with the real world and that.

comment:9 by Justin Lilly, 15 years ago

Owner: changed from nobody to Justin Lilly

Sure. I'll take this.

comment:10 by Jacob, 15 years ago

Needs documentation: set
Needs tests: set

Before this can go in:

  • passwd is a bit inside-baseball-y. Is there something wrong with change_password?
  • Needs documentation.
  • Needs tests.

by Justin Lilly, 15 years ago

Now with docs and renamed to change_password

comment:11 by Justin Lilly, 15 years ago

Needs documentation: unset

Added docs and changed passwd to change_password. Will need to do some more digging on the proper way to test these sorts of scripts.

comment:12 by Justin Lilly, 15 years ago

Needs tests: unset
Patch needs improvement: unset

Russel has given me special dispensation for making this patch a "manual test" due to the complications for testing it. Should be ready for review, then check in.

comment:13 by Chris Beaven, 15 years ago

Needs tests: set

It's not that complicated: monkeypatch the _get_pass method in your tests to return what you want without prompting.

comment:14 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

(In [12351]) Fixed #6273 -- Added a 'changepassword' management command. Thanks to Ludvig Ericson and Justin Lilly for their work on this patch.

Note: See TracTickets for help on using tickets.
Back to Top