import time
import urllib
+from types import StringTypes
+
from PLC.Debug import log
from PLC.Faults import *
from PLC.Method import Method
def call(self, auth, person_id_or_email, verification_key = None, verification_expires = None):
# Get account information
- persons = Persons(self.api, [person_id_or_email])
+ # we need to search in local objects only
+ if isinstance (person_id_or_email,StringTypes):
+ filter={'email':person_id_or_email}
+ else:
+ filter={'person_id':person_id_or_email}
+ filter['peer_id']=None
+ persons = Persons(self.api, filter)
if not persons:
raise PLCInvalidArgument, "No such account"
person = persons[0]
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"
'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']]
+ self.event_objects = {'Person': [person['person_id']]}
self.message = message_id
return 1