Example #1
0
    def authenticate(self):
        form_username = str(request.params.get('username'))
        form_password = str(request.params.get('password'))


        # Get user data from database
        user = Session.query(User).filter(User.name==form_username).first()

        if user is None: # User does not exist
            return render('/login.mako')

        # Wrong password? (MD5 hashes used here)
        
        #if user.password != md5.md5(form_password).hexdigest():
        if user.password != form_password:
            return "Bad authentication." #render('login.mako')

        # Mark user as logged in
        session['user'] = form_username
        session.save()

        if user.name == "admin":
            return redirect(url(controller='admin/menu', action='index'))
        else:
            return redirect(url.current(action='index'))
        """    
Example #2
0
    def get_today_order(self):
        o = Session.query(Order).filter(Order.date==datetime.date.today()).first()

        if o != None:
            c.details = Session.query(OrderDetail).filter(OrderDetail.order_id==o.id)
        else:
            c.details = None
        
        return render("/today_order.mako")
Example #3
0
 def index(self):
     
     if 'c' in request.params:
         c.category_id = int(request.params['c'])
     else:
         c.category_id = 1
         
     c.categories = Session.query(Category)
     c.authenticated = ('user' in session)
     
     return render("/menu.mako")
Example #4
0
 def login(self):
     return render('/login.mako')
Example #5
0
 def sign_up(self):
     return render('/signup.mako')
Example #6
0
 def index(self):
     return render('/home.mako')
Example #7
0
 def edit(self):
     id = request.params['user_id']
     c.user = Session.query(User).filter(User.id==id).first()
     return render('/admin/edit_user.mako')
Example #8
0
 def new(self):
     """GET /banners/new: Form to create a new item"""
     # url('new_banner')
     return render('/admin/new_user.mako')
Example #9
0
 def index(self):
     users = Session.query(User)
     c.users = users
     return render("/admin/users.mako")