X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FAddPersonKey.py;h=0c3628466d67562652f3906be910302253b0a4dc;hb=dec2f6cf93e4320722264e185ae8531c467c4692;hp=fb8113280532d7befe21d2106643816a9ae7936c;hpb=e347fc823bbba9d88a3fddf07d5c21024dfd1e55;p=plcapi.git diff --git a/PLC/Methods/AddPersonKey.py b/PLC/Methods/AddPersonKey.py index fb81132..0c36284 100644 --- a/PLC/Methods/AddPersonKey.py +++ b/PLC/Methods/AddPersonKey.py @@ -29,9 +29,6 @@ class AddPersonKey(Method): returns = Parameter(int, 'New key_id (> 0) if successful') - event_type = 'Add' - object_type = 'Key' - object_ids = [] def call(self, auth, person_id_or_email, key_fields): key_fields = dict(filter(can_update, key_fields.items())) @@ -42,6 +39,9 @@ class AddPersonKey(Method): raise PLCInvalidArgument, "No such account" person = persons[0] + if person['peer_id'] is not None: + raise PLCInvalidArgument, "Not a local account" + # If we are not admin, make sure caller is adding a key to their account if 'admin' not in self.caller['roles']: if person['person_id'] != self.caller['person_id']: @@ -51,6 +51,9 @@ class AddPersonKey(Method): key.sync(commit = False) person.add_key(key, commit = True) - self.object_ids = [person['person_id'], key['key_id']] + # Logging variables + self.object_ids = [person['person_id'], key['key_id']] + self.message = 'Key %d added to person %d' % \ + (key['key_id'], person['person_id']) return key['key_id']