1
# Copyright (C) 2002 by the Free Software Foundation, Inc.
3
# This program is free software; you can redistribute it and/or
4
# modify it under the terms of the GNU General Public License
5
# as published by the Free Software Foundation; either version 2
6
# of the License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
password [<oldpassword> <newpassword>] [address=<address>]
19
Retrieve or change your password. With no arguments, this returns
20
your current password. With arguments <oldpassword> and <newpassword>
21
you can change your password.
23
If you're posting from an address other than your membership address,
24
specify your membership address with `address=<address>' (no brackets
25
around the email address, and no quotes!). Note that in this case the
26
response is always sent to the subscribed address.
29
from email.Utils import parseaddr
31
from Mailman import mm_cfg
32
from Mailman.i18n import _
43
def process(res, args):
47
# They just want to get their existing password
48
realname, address = parseaddr(res.msg['from'])
49
if mlist.isMember(address):
50
password = mlist.getMemberPassword(address)
51
res.results.append(_('Your password is: %(password)s'))
53
listname = mlist.real_name
55
_('You are not a member of the %(listname)s mailing list'))
57
elif len(args) == 1 and args[0].startswith('address='):
58
# They want their password, but they're posting from a different
59
# address. We /must/ return the password to the subscribed address.
61
res.returnaddr = address
62
if mlist.isMember(address):
63
password = mlist.getMemberPassword(address)
64
res.results.append(_('Your password is: %(password)s'))
66
listname = mlist.real_name
68
_('You are not a member of the %(listname)s mailing list'))
71
# They are changing their password
74
realname, address = parseaddr(res.msg['from'])
75
if mlist.isMember(address):
76
if mlist.Authenticate((mm_cfg.AuthUser, mm_cfg.AuthListAdmin),
78
mlist.setMemberPassword(address, newpasswd)
79
res.results.append(_('Password successfully changed.'))
81
res.results.append(_("""\
82
You did not give the correct old password, so your password has not been
83
changed. Use the no argument version of the password command to retrieve your
84
current password, then try again."""))
85
res.results.append(_('\nUsage:'))
86
res.results.append(gethelp(mlist))
89
listname = mlist.real_name
91
_('You are not a member of the %(listname)s mailing list'))
93
elif len(args) == 3 and args[2].startswith('address='):
94
# They want to change their password, and they're sending this from a
95
# different address than what they're subscribed with. Be sure the
96
# response goes to the subscribed address.
100
res.returnaddr = address
101
if mlist.isMember(address):
102
if mlist.Authenticate((mm_cfg.AuthUser, mm_cfg.AuthListAdmin),
104
mlist.setMemberPassword(address, newpasswd)
105
res.results.append(_('Password successfully changed.'))
107
res.results.append(_("""\
108
You did not give the correct old password, so your password has not been
109
changed. Use the no argument version of the password command to retrieve your
110
current password, then try again."""))
111
res.results.append(_('\nUsage:'))
112
res.results.append(gethelp(mlist))
115
listname = mlist.real_name
117
_('You are not a member of the %(listname)s mailing list'))