def dispPage(self,request): cookie = request.getCookie('gtoken') if cookie: gitkit_user = gitkit_instance.VerifyGitkitToken(cookie) if gitkit_user: userdetails = {'display_name': gitkit_user.name, 'photo_url':gitkit_user.photo_url} if gitkit_user.photo_url is None: userdetails['photo_url']='/images/home/slider/slide1/cloud1.png' mycams = CamCheck().cbquery(gitkit_user.user_id) if len(mycams) > 0: myAES = AESCipher(key) cookie_data = {'user_id':gitkit_user.user_id,'cams':mycams,'time':long(time.time())} expiry = time.strftime("%a, %d-%b-%Y %T GMT", time.gmtime(time.time()+self.maxAge)) request.addCookie('wsid',myAES.encrypt(json.dumps(cookie_data)),expires=expiry,path=b"/") welcome = PSjinja_env.get_template('user_cam_details.html') request.write(welcome.render(user=userdetails,mycams=mycams).encode('utf-8')) else: request.setResponseCode(401) noauth = PSjinja_env.get_template('not_authorized.html') request.write(noauth.render().encode('utf-8')) else: request.setResponseCode(401) noauth = PSjinja_env.get_template('not_authorized.html') request.write(noauth.render().encode('utf-8')) return request
def cbDBRes(self,result,cambot,request): if len(result) == 0: master = None else: camid, master = result myAES = AESCipher(key) cambot['master'] = master expiry = time.strftime("%a, %d-%b-%Y %T GMT", time.gmtime(time.time()+self.maxAge)) cambot['expiry'] = expiry request.addCookie('wsid',myAES.encrypt(json.dumps(cambot)),expires=expiry,path=b"/") request.finish()