annotate MoinMoin/script/account/resetpw.py @ 6133:a6283e189869 tip

fixup: remove nonexisting passlib.utils._blowfish this was removed by the passlib 1.7.1 upgrade.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 01 Jun 2017 18:10:19 +0200
parents 77533e162654
children
rev   line source
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
2 """
5935
6f201a3b1b24 account resetpw: improve docs/help
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5917
diff changeset
3 MoinMoin - change or reset the password of a user account
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
4
5915
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
5 @copyright: 2006-2013 MoinMoin:ThomasWaldmann,
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
6 2008 MoinMoin:JohannesBerg
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
7 @license: GNU GPL, see COPYING for details.
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
8 """
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
9
6001
77533e162654 improve python2.5 compatibility (with_statement)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5959
diff changeset
10 from __future__ import with_statement
77533e162654 improve python2.5 compatibility (with_statement)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5959
diff changeset
11
5936
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
12 import sys
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
13
5915
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
14 from MoinMoin.script import MoinScript, log
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
15 from MoinMoin.user import getUserList, set_password, Fault
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
16
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
17
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
18 class PluginScript(MoinScript):
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
19 """\
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
20 Purpose:
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
21 ========
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
22 This tool allows you to change a user password via a command line interface.
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
23
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
24 Detailed Instructions:
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
25 ======================
5917
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
26 General syntax: moin [options] account resetpw [newpw-options] [newpassword]
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
27
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
28 [options] usually should be:
5437
a20de9383481 fix --wiki-url examples, needs http:// now
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3770
diff changeset
29 --config-dir=/path/to/my/cfg/ --wiki-url=http://wiki.example.org/
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
30
5917
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
31 newpassword:
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
32 The new password, optional. If newpassword is not given, the password will
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
33 be invalidated (and the user will not be able to log in with any password,
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
34 so the user will need to do a password recovery).
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
35
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
36 [newpw-options] see below:
3770
749d7148b080 script.account: create user checks for already known email adress or username,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3722
diff changeset
37 1. To change JohnSmith's password:
5935
6f201a3b1b24 account resetpw: improve docs/help
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5917
diff changeset
38 moin ... account resetpw --name JohnSmith JohnsNewSuperSecretPassword
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
39
3770
749d7148b080 script.account: create user checks for already known email adress or username,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3722
diff changeset
40 2. To change the password for the UID '1198872910.78.56322':
5935
6f201a3b1b24 account resetpw: improve docs/help
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5917
diff changeset
41 moin ... account resetpw --uid 1198872910.78.56322 TheNewPassword
5917
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
42
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
43 3. To invalidate the password of all users and notify them via e-mail,
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
44 giving verbose progress information:
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
45 moin ... --verbose account resetpw --all-users --notify
5935
6f201a3b1b24 account resetpw: improve docs/help
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5917
diff changeset
46
6f201a3b1b24 account resetpw: improve docs/help
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5917
diff changeset
47 Please note:
6f201a3b1b24 account resetpw: improve docs/help
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5917
diff changeset
48 - if you have many users, this will generate many e-mails
6f201a3b1b24 account resetpw: improve docs/help
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5917
diff changeset
49 - if a user does not have an e-mail address in his profile, he can not
6f201a3b1b24 account resetpw: improve docs/help
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5917
diff changeset
50 get notified
6f201a3b1b24 account resetpw: improve docs/help
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5917
diff changeset
51 - disabled user profiles will get the password reset, but won't get
6f201a3b1b24 account resetpw: improve docs/help
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5917
diff changeset
52 notified (they can't be used any more anyway).
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
53 """
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
54
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
55 def __init__(self, argv, def_values):
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
56 MoinScript.__init__(self, argv, def_values)
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
57 self.parser.add_option(
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
58 "--uid", metavar="UID", dest="uid",
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
59 help="Reset password for the user with user id UID."
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
60 )
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
61 self.parser.add_option(
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
62 "--name", metavar="NAME", dest="uname",
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
63 help="Reset password for the user with user name NAME."
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
64 )
5915
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
65 self.parser.add_option(
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
66 "-a", "--all-users", dest="all_users", action="store_true",
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
67 help="Reset password for ALL users."
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
68 )
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
69 self.parser.add_option(
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
70 "--notify", dest="notify", action="store_true",
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
71 help="Notify user(s), send them an E-Mail with a password reset link."
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
72 )
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
73 self.parser.add_option(
5936
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
74 "--subject", metavar="SUBJECT", dest="subject",
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
75 help="Subject text for the password reset notification E-Mail."
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
76 )
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
77 self.parser.add_option(
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
78 "--text-intro", metavar="TEXT_INTRO", dest="text_intro",
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
79 help="Intro text for the password reset notification E-Mail. Default: empty."
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
80 )
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
81 self.parser.add_option(
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
82 "--text-msg", metavar="TEXT_MSG", dest="text_msg",
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
83 help="Main text for the password reset notification E-Mail. Default: use the builtin standard message"
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
84 )
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
85 self.parser.add_option(
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
86 "--text-data", metavar="TEXT_DATA", dest="text_data",
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
87 help="Data template text for the password reset notification E-Mail. Default: use the builtin standard data template"
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
88 )
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
89 self.parser.add_option(
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
90 "--text-from-file", metavar="TEXT_DATA", dest="text_file",
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
91 help="Read full template for the password reset notification E-Mail from the given file, overrides --text-intro/msg/data. Default: None"
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
92 )
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
93 self.parser.add_option(
5959
63412f39e2b4 moin account resetpw: add option --skip-invalid to skip users with already invalidated pw hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5937
diff changeset
94 "--skip-invalid", dest="skip_invalid", action="store_true",
63412f39e2b4 moin account resetpw: add option --skip-invalid to skip users with already invalidated pw hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5937
diff changeset
95 help="If a user's password hash is already invalid (pw is already reset), skip this user."
63412f39e2b4 moin account resetpw: add option --skip-invalid to skip users with already invalidated pw hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5937
diff changeset
96 )
63412f39e2b4 moin account resetpw: add option --skip-invalid to skip users with already invalidated pw hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5937
diff changeset
97 self.parser.add_option(
5915
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
98 "-v", "--verbose", dest="verbose", action="store_true",
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
99 help="Verbose operation."
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
100 )
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
101
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
102 def mainloop(self):
5917
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
103 argc = len(self.args)
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
104 if argc < 1:
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
105 newpass = None
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
106 elif argc == 1:
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
107 newpass = self.args[0]
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
108 else:
c99f570e274a moin account resetpw: make password optional, to be able to set a invalid password
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5915
diff changeset
109 self.parser.error("too many arguments given")
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
110
5915
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
111 flags_given = self.options.uid or self.options.uname or self.options.all_users
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
112 if not flags_given:
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
113 self.parser.print_help()
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
114 sys.exit(1)
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
115
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
116 self.init_request()
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
117 request = self.request
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
118
5936
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
119 notify = self.options.notify
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
120 if notify and not request.cfg.mail_enabled:
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
121 print "This wiki is not enabled for mail processing. The --notify option requires this. Aborting..."
5937
9a9af7912a44 moin account resetpw: fix typo
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5936
diff changeset
122 sys.exit(1)
5936
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
123
5959
63412f39e2b4 moin account resetpw: add option --skip-invalid to skip users with already invalidated pw hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5937
diff changeset
124 skip_invalid = self.options.skip_invalid
5936
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
125 subject = self.options.subject
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
126 text_intro = self.options.text_intro
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
127 text_msg = self.options.text_msg
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
128 text_data = self.options.text_data
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
129 text_file = self.options.text_file
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
130
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
131 if text_file:
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
132 text_intro = ''
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
133 text_msg = ''
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
134 with open(text_file) as f:
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
135 text_data = f.read().decode('utf-8')
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
136
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
137 if self.options.uid:
5915
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
138 try:
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
139 set_password(request, newpass, uid=self.options.uid,
5959
63412f39e2b4 moin account resetpw: add option --skip-invalid to skip users with already invalidated pw hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5937
diff changeset
140 notify=notify, skip_invalid=skip_invalid,
63412f39e2b4 moin account resetpw: add option --skip-invalid to skip users with already invalidated pw hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5937
diff changeset
141 subject=subject,
5936
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
142 text_intro=text_intro, text_msg=text_msg, text_data=text_data)
5915
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
143 except Fault, err:
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
144 print str(err)
3722
0259bd2d0777 add resetpw script
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
145 elif self.options.uname:
5915
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
146 try:
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
147 set_password(request, newpass, uname=self.options.uname,
5959
63412f39e2b4 moin account resetpw: add option --skip-invalid to skip users with already invalidated pw hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5937
diff changeset
148 notify=notify, skip_invalid=skip_invalid,
63412f39e2b4 moin account resetpw: add option --skip-invalid to skip users with already invalidated pw hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5937
diff changeset
149 subject=subject,
5936
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
150 text_intro=text_intro, text_msg=text_msg, text_data=text_data)
5915
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
151 except Fault, err:
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
152 print str(err)
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
153 elif self.options.all_users:
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
154 uids = sorted(getUserList(request))
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
155 total = len(uids)
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
156 for nr, uid in enumerate(uids, start=1):
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
157 log("%05d / %05d - processing uid %s" % (nr, total, uid))
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
158 try:
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
159 set_password(request, newpass, uid=uid,
5959
63412f39e2b4 moin account resetpw: add option --skip-invalid to skip users with already invalidated pw hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5937
diff changeset
160 notify=notify, skip_invalid=skip_invalid,
63412f39e2b4 moin account resetpw: add option --skip-invalid to skip users with already invalidated pw hashes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5937
diff changeset
161 subject=subject,
5936
2d3352c547bc moin account resetpw - misc. improvements
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5935
diff changeset
162 text_intro=text_intro, text_msg=text_msg, text_data=text_data)
5915
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
163 except Fault, err:
19e8a1c50bda moin account resetpw - added options --all-users and --notify
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5437
diff changeset
164 print str(err)