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 index(self, login = None, email = None, password = None, next = None):
     if email and password:
         with session_scope() as s:
             user = User.query_by_email(s, email)
             if user:
                 cherrypy.session["user_id"] = user.id
         next = cherrypy.session["next"] if "next" in cherrypy.session else "/"
         raise cherrypy.HTTPRedirect(next)
     else:
         cherrypy.session["next"] = next
         return cherrypy.lib.static.serve_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../static/login/index.html"))
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 _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. 5
0
 def index(self, filter = ""):
     with session_scope() as s:
         return json.dumps(dict_user(user) for user in [User.list(s, filter)])
Esempio n. 6
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. 7
0
 def create(self, name, password, email, latitude, longitude, bio):
     user = User(name, password, email, latitude, longitude, bio)
     with session_scope() as s:
         s.add(user)
         return "OK"
     return "FAIL"
Esempio n. 8
0
 def index(self, filter=""):
     with session_scope() as s:
         return json.dumps(
             dict_user(user) for user in [User.list(s, filter)])