X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FVerifyPerson.py;h=a0fc304274a9a40f65d27da477730df732f58128;hb=8a488f82ba7892d6a6eb1265f0f327ec75b71149;hp=3f1591a5139383e412293b21e7e2cd432cb04635;hpb=2c876d2eed500bc20be5aaf0cbbcfb10c722544c;p=plcapi.git diff --git a/PLC/Methods/VerifyPerson.py b/PLC/Methods/VerifyPerson.py index 3f1591a..a0fc304 100644 --- a/PLC/Methods/VerifyPerson.py +++ b/PLC/Methods/VerifyPerson.py @@ -36,24 +36,24 @@ class VerifyPerson(Method): Auth(), Mixed(Person.fields['person_id'], Person.fields['email']), - Person.fields['verification_key'], + Person.fields['verification_key'], Person.fields['verification_expires'] ] returns = Parameter(int, '1 if verification_key is valid') def call(self, auth, person_id_or_email, verification_key = None, verification_expires = None): - # Get account information + # Get account information persons = Persons(self.api, [person_id_or_email]) if not persons: - raise PLCInvalidArgument, "No such account" + raise PLCInvalidArgument, "No such account %r"%person_id_or_email person = persons[0] if person['peer_id'] is not None: - raise PLCInvalidArgument, "Not a local account" + raise PLCInvalidArgument, "Not a local account %r"%person_id_or_email if person['enabled']: - raise PLCInvalidArgument, "Account must be new (disabled)" + raise PLCInvalidArgument, "Account %r must be new (disabled)"%person_id_or_email # Get the primary site name person_sites = Sites(self.api, person['site_ids']) @@ -68,9 +68,9 @@ class VerifyPerson(Method): random_key = base64.b64encode("".join(map(chr, bytes))) if verification_key is None or \ - (verification_key is not None and person['verification_expires'] and \ - person['verification_expires'] < time.time()): - # Only allow one verification at a time + (verification_key is not None and person['verification_expires'] and \ + person['verification_expires'] < time.time()): + # Only allow one verification at a time if person['verification_expires'] is not None and \ person['verification_expires'] > time.time(): raise PLCPermissionDenied, "Verification request already pending" @@ -89,12 +89,12 @@ class VerifyPerson(Method): message_id = 'Verify account' - elif verification_key is not None: + elif verification_key is not None: if person['verification_key'] is None or \ person['verification_expires'] is None: raise PLCPermissionDenied, "Invalid Verification key" elif person['verification_key'] != verification_key: - raise PLCPermissionDenied, "Verification key incorrect" + raise PLCPermissionDenied, "Verification key incorrect" else: person['verification_key'] = None person['verification_expires'] = None @@ -145,12 +145,12 @@ class VerifyPerson(Method): else: print >> log, "Warning: No message template '%s'" % message_id - # Logging variables - self.object_ids = [person['person_id']] + # Logging variables + self.event_objects = {'Person': [person['person_id']]} self.message = message_id - - if verification_key is not None and person['verification_expires'] and \ + + if verification_key is not None and person['verification_expires'] and \ person['verification_expires'] < time.time(): - raise PLCPermissionDenied, "Verification key has expired. Another email has been sent." + raise PLCPermissionDenied, "Verification key has expired. Another email has been sent." return 1