Esempio n. 1
0
 def profile(self):
     cherrypy.response.status = 200
     with session_scope() as s:
         user = User.query_by_id(s, cherrypy.request.user_id)
         cherrypy.session["variables"] = {
             "user_name": user.name,
             "user_email": user.email
         }
Esempio n. 2
0
    def _fetch(self):
        login_url = "/login?next=%s" % urllib.parse.quote(cherrypy.url())
        if 'user_id' not in cherrypy.session:  # not authenticated
            cherrypy.lib.cptools.redirect(login_url)

        with session_scope() as s:
            user = User.query_by_id(s, cherrypy.session['user_id'])
            if user:
                cherrypy.request.user_id = user.id  # store the user for the request
            else:  # invalid user ID
                cherrypy.lib.cptools.redirect(login_url)
Esempio n. 3
0
 def _fetch(self):
     login_url = "/login?next=%s" % urllib.parse.quote(cherrypy.url())
     if 'user_id' not in cherrypy.session: # not authenticated
         cherrypy.lib.cptools.redirect(login_url)
     
     with session_scope() as s:
         user = User.query_by_id(s, cherrypy.session['user_id'])
         if user:
             cherrypy.request.user_id = user.id # store the user for the request
         else: # invalid user ID
             cherrypy.lib.cptools.redirect(login_url)
Esempio n. 4
0
 def profile(self):
     cherrypy.response.status = 200
     with session_scope() as s:
         user = User.query_by_id(s, cherrypy.request.user_id)
         cherrypy.session["variables"] = {"user_name": user.name, "user_email": user.email}