X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FAddSession.py;h=32da2019986f18afb8c105279a8a636b6b9812bd;hb=c63e5f873b83934324631c46d90884d005675853;hp=c5c55453cdb79a8104384f9a8cbc3e363e065e32;hpb=77e4f177dfee85705c36298c3230b2e4a3e73467;p=plcapi.git diff --git a/PLC/Methods/AddSession.py b/PLC/Methods/AddSession.py index c5c5545..32da201 100644 --- a/PLC/Methods/AddSession.py +++ b/PLC/Methods/AddSession.py @@ -1,4 +1,3 @@ -# $Id$ import time from PLC.Method import Method @@ -9,30 +8,30 @@ from PLC.Persons import Person, Persons class AddSession(Method): """ - Creates and returns a new session key for the specified user. + Creates and returns a new session key for the specified user. (Used for website 'user sudo') """ roles = ['admin'] accepts = [ - Auth(), - Mixed(Person.fields['person_id'], + Auth(), + Mixed(Person.fields['person_id'], Person.fields['email']) - ] + ] returns = Session.fields['session_id'] - + def call(self, auth, person_id_or_email): - - persons = Persons(self.api, [person_id_or_email], ['person_id', 'email']) - - if not persons: - raise PLCInvalidArgument, "No such person" - - person = persons[0] - session = Session(self.api) + + persons = Persons(self.api, [person_id_or_email], ['person_id', 'email']) + + if not persons: + raise PLCInvalidArgument, "No such person" + + person = persons[0] + session = Session(self.api) session['expires'] = int(time.time()) + (24 * 60 * 60) - session.sync(commit = False) - session.add_person(person, commit = True) + session.sync(commit = False) + session.add_person(person, commit = True) return session['session_id']