def dispatch(self):
		self.session_store = sessions.get_store(request=self.request)
		session = self.session_store.get_session()
		User.setCurrentUser(session.get('user'))
		try:
			webapp2.RequestHandler.dispatch(self)
		finally:
			self.session_store.save_sessions(self.response)
Beispiel #2
0
	def post(self):
		if self.session.get('user'):
			del self.session['user']
		data = json.loads(self.request.body)
		user = User.setCurrentUser(data.get('email'))
		if user:
			if user.verify(data['password']):
				self.session['user'] = user.email
				self.response.write('{"success":true}')
			else:
				self.response.write('{"success":false,"reason":"Sorry, we were unable to log you in because your password is incorrect"}')
		else:
			self.response.write('{"success":false,"reason":"Sorry, we do not recognise your email address"}')