X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FResetPassword.py;h=1486a821a0d9a519fbda911b8a34ff5d710e5ef1;hb=90a9c8342a4f5bcf02e6407dcf4ed1975ad15baf;hp=dd76a03de2c5a3d3f12f6100a50f3602fd4eafed;hpb=e25d1555c7f4854e71f3082da697eb0b0f3c7733;p=plcapi.git diff --git a/PLC/Methods/ResetPassword.py b/PLC/Methods/ResetPassword.py index dd76a03d..1486a821 100644 --- a/PLC/Methods/ResetPassword.py +++ b/PLC/Methods/ResetPassword.py @@ -49,6 +49,9 @@ class ResetPassword(Method): if person['peer_id'] is not None: raise PLCInvalidArgument, "Not a local account" + if not person['enabled']: + raise PLCInvalidArgument, "Account must be enabled" + # Be paranoid and deny password resets for admins if 'admin' in person['roles']: raise PLCInvalidArgument, "Cannot reset admin passwords" @@ -104,11 +107,11 @@ class ResetPassword(Method): 'email': person['email']} sendmail(self.api, - To = "%s %s <%s>" % (person['first_name'], person['last_name'], person['email']), - Subject = message['subject'], + To = ("%s %s" % (person['first_name'], person['last_name']), person['email']), + Subject = message['subject'] % params, Body = message['template'] % params) else: - print >> log, "Warning: No message template '%s'" % message-id + print >> log, "Warning: No message template '%s'" % message_id # Logging variables self.object_ids = [person['person_id']]