Mercurial > public > src > moin > 1.9
changeset 5959:63412f39e2b4
moin account resetpw: add option --skip-invalid to skip users with already invalidated pw hashes
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Tue, 12 Mar 2013 21:44:49 +0100 |
parents | ddb9a64cc1ec |
children | d8d1a130ee28 |
files | MoinMoin/script/account/resetpw.py MoinMoin/user.py |
diffstat | 2 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/script/account/resetpw.py Mon Mar 11 20:30:37 2013 +0100 +++ b/MoinMoin/script/account/resetpw.py Tue Mar 12 21:44:49 2013 +0100 @@ -89,6 +89,10 @@ help="Read full template for the password reset notification E-Mail from the given file, overrides --text-intro/msg/data. Default: None" ) self.parser.add_option( + "--skip-invalid", dest="skip_invalid", action="store_true", + help="If a user's password hash is already invalid (pw is already reset), skip this user." + ) + self.parser.add_option( "-v", "--verbose", dest="verbose", action="store_true", help="Verbose operation." ) @@ -115,6 +119,7 @@ print "This wiki is not enabled for mail processing. The --notify option requires this. Aborting..." sys.exit(1) + skip_invalid = self.options.skip_invalid subject = self.options.subject text_intro = self.options.text_intro text_msg = self.options.text_msg @@ -130,14 +135,16 @@ if self.options.uid: try: set_password(request, newpass, uid=self.options.uid, - notify=notify, subject=subject, + notify=notify, skip_invalid=skip_invalid, + subject=subject, text_intro=text_intro, text_msg=text_msg, text_data=text_data) except Fault, err: print str(err) elif self.options.uname: try: set_password(request, newpass, uname=self.options.uname, - notify=notify, subject=subject, + notify=notify, skip_invalid=skip_invalid, + subject=subject, text_intro=text_intro, text_msg=text_msg, text_data=text_data) except Fault, err: print str(err) @@ -148,7 +155,8 @@ log("%05d / %05d - processing uid %s" % (nr, total, uid)) try: set_password(request, newpass, uid=uid, - notify=notify, subject=subject, + notify=notify, skip_invalid=skip_invalid, + subject=subject, text_intro=text_intro, text_msg=text_msg, text_data=text_data) except Fault, err: print str(err)
--- a/MoinMoin/user.py Mon Mar 11 20:30:37 2013 +0100 +++ b/MoinMoin/user.py Tue Mar 12 21:44:49 2013 +0100 @@ -195,13 +195,15 @@ def set_password(request, newpass, u=None, uid=None, uname=None, - notify=False, subject=None, + notify=False, skip_invalid=False, subject=None, text_intro=None, text_msg=None, text_data=None): if uid: u = User(request, uid) elif uname: u = User(request, auth_username=uname) if u and u.exists(): + if skip_invalid and u.enc_password == '': + return if not newpass: # set a invalid password hash u.enc_password = ''