Esempio n. 1
0
 def post(self):
     username = self.request.get('username')
     password = self.request.get('password')
     verify = self.request.get('verify')
     email = self.request.get('email')
     have_error = False
     params = dict(username = username, email = email)
     
     # Valid input
     if not generic.valid_input(username, USERNAME_RE):
         params['error_username'] = "******"
         have_error = True
     elif db.GqlQuery("select * from User where username = '******'" % username).get():
         params['error_username'] = "******"
         have_error = True
     if not generic.valid_input(password, PASSWORD_RE):
         params['error_password'] = "******"
         have_error = True
     elif password != verify:
         params['error_verify'] = "Las contrasenas no coinciden."
         have_error = True
     if email and not generic.valid_input(email, EMAIL_RE):
         params['error_email'] = "Esa no parece ser una direccion de correo electronico valida."
         have_error = True
         
     if have_error:
         self.render('registro.html', **params)
     else:
         salt = generic.make_salt()
         ph = generic.hash_str(password + salt)
         u = generic.User(username = username, password_hash = ph, salt = salt)
         u.put()
         user_cookie_val = 'username=%s; Path=/' % generic.make_secure_val(username)
         self.response.headers.add_header('Set-Cookie', str(user_cookie_val))
         self.redirect('/bienvenido')
Esempio n. 2
0
    def post(self):
        username = self.request.get('username')
        password = self.request.get('password')
        have_error = False
        params = dict(username = username, password = password)
        if not username:
            params['error_username'] = '******'
            have_error = True
        if not password:
            params['error_password'] = '******'
            have_error = True
        if not generic.hash_str(password + generic.User.all().filter('username ='******'username ='******'error_password'] = '******'
            have_error = True

        if have_error:
            self.render('login.html', **params)
        else:
            user_cookie_val = 'username=%s; Path=/' % generic.make_secure_val(username)
            self.response.headers.add_header('Set-Cookie', str(user_cookie_val))
            self.render('bienvenido.html', username = username)