def request(self): # check for login if not session.logged_in: return WebOpenIDLoginRequired(self.query) items = [ (( item[1], web.ctx.homedomain + web.url('/account/trusted/%s/delete' % item[0]) )) for item in trust_root_store.items() ] removed = session.get('trusted_removed_successful', False) session['trusted_removed_successful'] = False web.header('Content-type', 'text/html') return render.trusted( logged_in=session.logged_in, logout_url=web.ctx.homedomain + web.url('/account/logout'), change_password_url=web.ctx.homedomain + web.url('/account/change_password'), no_password=session.get('no_password', False), trusted=items, removed=removed, )
def request(self): # check for login if not session.logged_in: return WebOpenIDLoginRequired(self.query) form = WebOpenIDChangePasswordForm() if self.method == 'POST': if form.validates(self.query): password_manager.set(self.query['password']) session['no_password'] = False return web.found( _secure_homedomain(web.ctx) + web.url('/account')) web.header('Content-type', 'text/html') return render.password( home_url=_secure_homedomain(web.ctx) + web.url('/'), logged_in=session.logged_in, logout_url=_secure_homedomain(web.ctx) + web.url('/account/logout'), change_password_url=_secure_homedomain(web.ctx) + web.url('/account/change_password'), no_password=session.get('no_password', False), form=form, )
def request(self, trusted_id): # check for login if not session.logged_in: return WebOpenIDLoginRequired(self.query) try: trust_root = dict(trust_root_store.items())[trusted_id] except: return web.notfound() if self.method == 'POST': trust_root_store.delete(trust_root) session['trusted_removed_successful'] = True return web.found(web.ctx.homedomain + web.url('/account/trusted')) web.header('Content-type', 'text/html') return render.trusted_confirm( logged_in=session.logged_in, logout_url=web.ctx.homedomain + web.url('/account/logout'), change_password_url=web.ctx.homedomain + web.url('/account/change_password'), check_trusted_url=web.ctx.homedomain + web.url('/account/trusted'), trusted_remove_url=web.ctx.homedomain + web.url('/account/trusted/%s/delete' % trusted_id), no_password=session.get('no_password', False), trust_root=trust_root, )
def menu(): menuData = cache.get('menu') if menuData is None: html = session.get("http://teamportal/sites/admin/Culinary/Lists/Menu Items/Simplified.aspx").text soup = BeautifulSoup(html) today = datetime.today() today_str = " : {}/{}/{}".format(today.month, today.day, today.year) today_element = soup.find_all(text=today_str, limit=1) menu_tbody = today_element[0].parent.parent.parent.next_sibling menuData = {} for tr in menu_tbody.next_siblings: if not tr.contents: break if not tr.contents[0].string: continue category = tr.contents[0].string name = tr.contents[1].string price = tr.contents[2].string if category in menuData: menuData[category].append((name, price)) else: menuData[category] = [(name, price)] menuData = json.dumps(menuData) cache.set('menu', menuData , timeout=14400) # cache will last 4 hours return menuData
def GET(self): web.header("Content-Type", "text/html") if session.get("logged_in", False): return open("./frontend/index.html", "rb") else: session.logged_in = False raise web.seeother("/logIn")
def request(self): # check for login if not session.logged_in: return WebOpenIDLoginRequired(self.query) form = WebOpenIDChangePasswordForm() if self.method == 'POST': if form.validates(self.query): password_manager.set(self.query['password']) session['no_password'] = False return web.found( homedomain(web.ctx) + web.url('/account')) web.header('Content-type', 'text/html') return render.password( home_url=homedomain(web.ctx) + web.url('/'), logged_in=session.logged_in, logout_url=homedomain(web.ctx) + web.url('/account/logout'), change_password_url=homedomain(web.ctx) + web.url( '/account/change_password'), no_password=session.get('no_password', False), form=form, )
def request(self): return_to = self.query.get('return_to', web.ctx.homedomain + web.url('/account')) data = filter(lambda item: item[0] not in ['password'], self.query.items()) form = WebOpenIDLoginForm(password_manager)() session['no_password'] = False if self.method == 'POST': try: if form.validates(self.query): session.login() data.append(('logged_in', True)) return web.found(return_to + '?' + web.http.urlencode(dict(data))) except PasswordManager.NoPassword: session['no_password'] = True session.login() data.append(('logged_in', True)) return web.found(return_to + '?' + web.http.urlencode(dict(data))) web.header('Content-type', 'text/html') return render.login( logged_in=session.logged_in, login_url=web.ctx.homedomain + web.url('/account/login'), logout_url=web.ctx.homedomain + web.url('/account/logout'), change_password_url=web.ctx.homedomain + web.url('/account/change_password'), no_password=session.get('no_password', False), form=form, query=data, )
def request(self, trusted_id): # check for login if not session.logged_in: return WebOpenIDLoginRequired(self.query) try: trust_root = dict(trust_root_store.items())[trusted_id] except: return web.notfound() if self.method == 'POST': trust_root_store.delete(trust_root) session['trusted_removed_successful'] = True return web.found( _secure_homedomain(web.ctx) + web.url('/account/trusted')) web.header('Content-type', 'text/html') return render.trusted_confirm( home_url=_secure_homedomain(web.ctx) + web.url('/'), logged_in=session.logged_in, logout_url=_secure_homedomain(web.ctx) + web.url('/account/logout'), change_password_url=_secure_homedomain(web.ctx) + web.url('/account/change_password'), check_trusted_url=_secure_homedomain(web.ctx) + web.url('/account/trusted'), trusted_remove_url=_secure_homedomain(web.ctx) + web.url('/account/trusted/%s/delete' % trusted_id), no_password=session.get('no_password', False), trust_root=trust_root, )
def GET(self): web.header("Content-Type", "text/html") if session.get("logged_in", False): if session.user.has_access(config["pages"], "load_orders"): return frontend_files["load_orders.html"] return frontend_files["no_access.html"] else: raise web.seeother("/logIncargar_orders")
def GET(self): web.header("Content-Type", "text/html") if session.get("logged_in", False): if session.user.has_access(config["pages"], "machines"): return open("./frontend/machines.html", "rb") return open("./frontend/no_access.html", "rb") else: raise web.seeother("/logInmaquinas")
def test(name): name += request.path_info u = session.get('user') login = session.get('login') # if not session.get('user'): # raise Redirect('http://www.localhost') # raise Redirect('/hi/go/baby') res = Response("test on session user %s,logined:%s" % (u, login)) # res.set_cookie('hello', 'hahaha') # res.add_header('Content-Type', 'text/plain') # print request.cookie # print request.environ # print request.form.get('a') # print request.get_cookie('helloo') session.set('user', 'aka') session.set('login', True) return res
def request(self): web.header('Content-type', 'text/html') return render.base( logged_in=session.logged_in, login_url=web.ctx.homedomain + web.url('/account/login'), logout_url=web.ctx.homedomain + web.url('/account/logout'), change_password_url=web.ctx.homedomain + web.url('/account/change_password'), check_trusted_url=web.ctx.homedomain + web.url('/account/trusted'), no_password=session.get('no_password', False), endpoint=web.ctx.homedomain + web.url('/endpoint'), yadis=web.ctx.homedomain + web.url('/yadis.xrds'), )
def request(self): # check for login if not session.logged_in: return WebOpenIDLoginRequired(self.query) items = [((item[1], _secure_homedomain(web.ctx) + web.url('/account/trusted/%s/delete' % item[0]))) for item in trust_root_store.items()] removed = session.get('trusted_removed_successful', False) session['trusted_removed_successful'] = False web.header('Content-type', 'text/html') return render.trusted( home_url=_secure_homedomain(web.ctx) + web.url('/'), logged_in=session.logged_in, logout_url=_secure_homedomain(web.ctx) + web.url('/account/logout'), change_password_url=_secure_homedomain(web.ctx) + web.url('/account/change_password'), no_password=session.get('no_password', False), trusted=items, removed=removed, )
def request(self): web.header('Content-type', 'text/html') return render.base( home_url=_secure_homedomain(web.ctx) + web.url('/'), logged_in=session.logged_in, login_url=_secure_homedomain(web.ctx) + web.url('/account/login'), logout_url=_secure_homedomain(web.ctx) + web.url('/account/logout'), change_password_url=_secure_homedomain(web.ctx) + web.url('/account/change_password'), check_trusted_url=_secure_homedomain(web.ctx) + web.url('/account/trusted'), no_password=session.get('no_password', False), endpoint=_secure_homedomain(web.ctx) + web.url('/endpoint'), yadis=_secure_homedomain(web.ctx) + web.url('/yadis.xrds'), )
def request(self): return_to = self.query.get( 'return_to', _secure_homedomain(web.ctx) + web.url('/account')) data = filter(lambda item: item[0] not in ['password'], self.query.items()) form = WebOpenIDLoginForm(password_manager)() session['no_password'] = False if self.method == 'POST': try: if form.validates(self.query): session.login() data.append(('logged_in', True)) return web.found(return_to + '?' + web.http.urlencode(dict(data))) except PasswordManager.NoPassword: session['no_password'] = True session.login() data.append(('logged_in', True)) return web.found(return_to + '?' + web.http.urlencode(dict(data))) web.header('Content-type', 'text/html') return render.login( home_url=_secure_homedomain(web.ctx) + web.url('/'), logged_in=session.logged_in, login_url=_secure_homedomain(web.ctx) + web.url('/account/login'), logout_url=_secure_homedomain(web.ctx) + web.url('/account/logout'), change_password_url=_secure_homedomain(web.ctx) + web.url('/account/change_password'), no_password=session.get('no_password', False), form=form, query=data, )
def GET(self, redirect): web.header("Content-Type", "text/html") if not session.get("logged_in", False): return open("./frontend/log_in.html", "rb") else: raise web.seeother("/" + redirect)
def request(self): # check for login if not session.logged_in: return WebOpenIDLoginRequired(self.query) request = server.request( _secure_homedomain(web.ctx) + web.url('/endpoint'), self.query) try: response = request.process(logged_in=True) except OpenIDResponse.NoneRequest: return web.badrequest() except OpenIDResponse.DecisionNeed: if self.method == 'POST': if self.query.get('logout', False): session.logout() if self.query.has_key('approve'): response = request.approve() elif self.query.has_key('always'): response = request.always() else: response = request.decline() else: data = filter( lambda item: item[0] not in ['approve', 'always', 'logged_in', 'logout'], self.query.items()) sreg_request = sreg.SRegRequest.fromOpenIDRequest( request.request) profile = None if sreg_request.required or sreg_request.optional: try: hcards = HCardParser().parse_url( request.request.identity) if hcards: hcard = hcards.next() profile = hcard.profile(sreg_request.required, sreg_request.optional) except: pass logout_form = WebOpenIDLogoutForm() logout_form.fill( {'logout': self.query.get('logged_in', False)}) web.header('Content-type', 'text/html') return render.verify( home_url=_secure_homedomain(web.ctx) + web.url('/'), logged_in=session.logged_in, logout_url=_secure_homedomain(web.ctx) + web.url('/account/logout'), change_password_url=_secure_homedomain(web.ctx) + web.url('/account/change_password'), no_password=session.get('no_password', False), decision_url=_secure_homedomain(web.ctx) + web.url('/account/decision'), identity=request.request.identity, trust_root=request.request.trust_root, profile=profile, logout_form=logout_form, query=data, ) return render_openid_to_response(response)
def GET(self): web.header("Content-Type", "text/html") if session.get("logged_in", False): return open("./frontend/board.html", "rb") else: raise web.seeother("/logInpizarra")
def logged_in(self): return session.get('logged_in', False)
def manage_index(): """index page""" email = session.get('email') name = session.get('name') return render_template('manage.html', name=name, email=email)
def GET(self): web.header("Content-Type", "text/html") if session.get("logged_in", False): return frontend_files["my_user.html"] else: raise web.seeother("/logInmi_usuario")
def logged(): return session.get('login') == 1
def decorator(*args, **kwargs): if not session.get('user'): raise Redirect('http://localhost') return func(*args, **kwargs)
def request(self): # check for login if not session.logged_in: return WebOpenIDLoginRequired(self.query) request = server.request(web.ctx.homedomain + web.url('/endpoint'), self.query) try: response = request.process(logged_in=True) except OpenIDResponse.NoneRequest: return web.badrequest() except OpenIDResponse.DecisionNeed: if self.method == 'POST': if self.query.get('logout', False): session.logout() if self.query.has_key('approve'): response = request.approve() elif self.query.has_key('always'): response = request.always() else: response = request.decline() else: data = filter( lambda item: item[0] not in [ 'approve', 'always', 'logged_in', 'logout' ], self.query.items()) sreg_request = sreg.SRegRequest.fromOpenIDRequest(request.request) profile = None if sreg_request.required or sreg_request.optional: try: hcards = HCardParser().parse_url(request.request.identity) if hcards: hcard = hcards.next() profile = hcard.profile(sreg_request.required, sreg_request.optional) except: pass logout_form = WebOpenIDLogoutForm() logout_form.fill({'logout': self.query.get('logged_in', False)}) web.header('Content-type', 'text/html') return render.verify( logged_in=session.logged_in, logout_url=web.ctx.homedomain + web.url('/account/logout'), change_password_url=web.ctx.homedomain + web.url('/account/change_password'), no_password=session.get('no_password', False), decision_url=web.ctx.homedomain + web.url('/account/decision'), identity=request.request.identity, trust_root=request.request.trust_root, profile=profile, logout_form=logout_form, query=data, ) return render_openid_to_response(response)
def current_user(): user = session.get('user') if not user: return dict(logged=False) return dict(logged=True, user=user)