Exemple #1
0
 def submit(self):
     user = User.getByUsername(self.cleaned_data['username'])
     if not user:
         raise SessionAuthorizationException()
     
     if not user.authenticate(self.cleaned_data['password']):
         raise SessionAuthorizationException()
     
     self.cleaned_data['user_id'] = UUID(user.user_id)
     del self.cleaned_data['username']
     del self.cleaned_data['password']
     session = Session.fromMap(self.cleaned_data)
 
     session.save()
     return SessionSerializer(session).data
Exemple #2
0
 def delete(self, session_id):
     r = requests.delete(self.url + '/rest/v1/sessions/%s' % str(session_id))
     if r.status_code is not 200:
         raise SessionClientError(r.text)
     return Session.fromMap(r.json())
Exemple #3
0
 def create(self, username, password):
     payload = { 'username':username, 'password':password }
     r = requests.post(self.url + '/rest/v1/sessions',data=payload)
     if r.status_code is not 200:
         raise SessionClientError(r.text)
     return Session.fromMap(r.json())