- remove PLCCheckLocal functions, be more explicit about the error in
[plcapi.git] / PLC / Methods / UpdatePerson.py
index 71c47bf..85c4a71 100644 (file)
@@ -40,8 +40,10 @@ class UpdatePerson(Method):
         persons = Persons(self.api, [person_id_or_email])
         if not persons:
             raise PLCInvalidArgument, "No such account"
+        person = persons[0]
 
-        person = persons.values()[0]
+        if person['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local account"
 
         # Authenticated function
         assert self.caller is not None
@@ -52,5 +54,16 @@ class UpdatePerson(Method):
 
         person.update(person_fields)
         person.sync()
+       
+       # Logging variables
+       self.object_ids = [person['person_id']]
+
+        # Redact password
+        if 'password' in person_fields:
+            person_fields['password'] = "Removed by API"
+        self.message = 'Person %d updated: %s.' % \
+                       (person['person_id'], person_fields.keys())
+       if 'enabled' in person_fields:
+            self.message += ' Person enabled'  
 
         return 1