X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FDeletePerson.py;h=448f8085ee188a551d3afc6b8cd7c2ec7dbedc5c;hb=refs%2Fheads%2Fplanetlab-4_0-branch;hp=8375439bd80d92da143b81175a42a4c9d2e901e3;hpb=40d33ca5c3e174e3ac07e3519c07e43825b4c797;p=plcapi.git diff --git a/PLC/Methods/DeletePerson.py b/PLC/Methods/DeletePerson.py index 8375439..448f808 100644 --- a/PLC/Methods/DeletePerson.py +++ b/PLC/Methods/DeletePerson.py @@ -2,7 +2,7 @@ from PLC.Faults import * from PLC.Method import Method from PLC.Parameter import Parameter, Mixed from PLC.Persons import Person, Persons -from PLC.Auth import PasswordAuth +from PLC.Auth import Auth class DeletePerson(Method): """ @@ -18,7 +18,7 @@ class DeletePerson(Method): roles = ['admin', 'pi', 'user', 'tech'] accepts = [ - PasswordAuth(), + Auth(), Mixed(Person.fields['person_id'], Person.fields['email']) ] @@ -30,8 +30,10 @@ class DeletePerson(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 @@ -41,5 +43,9 @@ class DeletePerson(Method): raise PLCPermissionDenied, "Not allowed to delete specified account" person.delete() + + # Logging variables + self.event_objects = {'Person': [person['person_id']]} + self.message = 'Person %d deleted' % person['person_id'] return 1