Example #1
0
    def create(self):
        c.page = 'sign up'
        if request.environ['REQUEST_METHOD'] == 'GET':
            return render('/signup/form.mako')
        elif request.environ['REQUEST_METHOD'] == 'POST':
            username = request.params['username']
            password = request.params['password']
            password_confirm = request.params['password_confirm']
            email = request.params['email']

            validity = validate_signup(username, password, password_confirm,
                                       email)
            if not validity['status']:
                h.add_message(validity['msg'], 'error')
                return render('/signup/form.mako')
            try:
                create_user(username, password, email)
                authenticate(username, password)
                c.logged_in = True
                c.user = db.query(User).filter(
                    User.username == username).first()
                return render('/signup/success.mako')
            except NameError, e:
                h.add_message(e.__str__(), 'error')
                return render('/signup/form.mako')
Example #2
0
 def create(self):
     c.page = 'sign up'
     if request.environ['REQUEST_METHOD'] == 'GET':
         return render('/signup/form.mako')
     elif request.environ['REQUEST_METHOD'] == 'POST':
         username = request.params['username']
         password = request.params['password']
         password_confirm = request.params['password_confirm']
         email = request.params['email']
         
         validity = validate_signup(username, password,
                                    password_confirm, email)
         if not validity['status']:
             h.add_message(validity['msg'], 'error')
             return render('/signup/form.mako')
         try:
             create_user(username, password, email)
             authenticate(username, password)
             c.logged_in = True
             c.user = db.query(User).filter(User.username == username).first()
             return render('/signup/success.mako')
         except NameError, e:
             h.add_message(e.__str__, 'error')
             return render('/signup/form.mako')
Example #3
0
 def login(self):
     c.page = 'log in'
     c.redirect_url = request.GET.get('redirect_url', '')
     if request.environ['REQUEST_METHOD'] == 'GET':
         if request.GET.get('warn', ''):
             h.add_message('You need to be logged in to perform that action.',
                           'info')
         return render('/login.mako')
     elif request.environ['REQUEST_METHOD'] == 'POST':
         username = request.params['username']
         password = request.params['password']
         success = authenticate(username, password)
         if success:
             if c.redirect_url and not c.redirect_url in ['/signup', 
                                                          '/logout']:
                 redirect(c.redirect_url)
             else:
                 redirect(url(controller='home', action='main'))
         else:
             h.add_message('Incorrect username / password', 'error')
             return render('/login.mako')
Example #4
0
 def login(self):
     c.page = 'log in'
     c.redirect_url = request.GET.get('redirect_url', '')
     if request.environ['REQUEST_METHOD'] == 'GET':
         if request.GET.get('warn', ''):
             h.add_message(
                 'You need to be logged in to perform that action.', 'info')
         return render('/login.mako')
     elif request.environ['REQUEST_METHOD'] == 'POST':
         username = request.params['username']
         password = request.params['password']
         success = authenticate(username, password)
         if success:
             if c.redirect_url and not c.redirect_url in [
                     '/signup', '/logout', '/reset_password'
             ]:
                 redirect(c.redirect_url)
             else:
                 redirect(url(controller='home', action='main'))
         else:
             h.add_message('Incorrect username / password', 'error')
             return render('/login.mako')