Пример #1
0
    def post(self):
        have_error = False

        self.next_url = str(self.request.get('next_url'))
        if not self.next_url or self.next_url.startswith('/login'):
            self.next_url = '/'

        self.username = self.request.get('username')
        self.password = self.request.get('password')
        self.verify = self.request.get('verify')
        self.email = self.request.get('email')

        params = dict(username = self.username,
                      email = self.email)

        if not valid_username(self.username):
            params['error_username'] = "******"
            have_error = True

        if not valid_password(self.password):
            params['error_password'] = "******"
            have_error = True
        elif self.password != self.verify:
            params['error_verify'] = "Your passwords didn't match."
            have_error = True

        if not valid_email(self.email):
            params['error_email'] = "That's not a valid email."
            have_error = True

        if have_error:
            self.render('signup-form.html', **params)
        else:
            self.done()
Пример #2
0
    def post(self):
        have_error = False
        self.username = self.request.get('username')
        self.password = self.request.get('password')
        self.verify = self.request.get('verify')
        self.email = self.request.get('email')

        # Build up dict of error messages to rerender form with on
        # error case (always include username and e-mail, never pw)
        error_params = {'username': self.username, 'email': self.email}

        # If statements will set have_error=True if validation
        # procedures return False
        if not u.valid_username(self.username):
            error_params['error_username'] = "******"
            have_error = True

        # We can either have an invalid pw or the pw's don't match up
        if not u.valid_password(self.password):
            error_params['error_password'] = "******"
            have_error = True
        elif self.password != self.verify:
            error_params['error_verify'] = "Your passwords didn't match."
            have_error = True

        if not u.valid_email(self.email):
            error_params['error_email'] = "That's not a valid e-mail."
            have_error = True

        if have_error:
            self.render_signup(**error_params)
        else:
            self.welcome()
Пример #3
0
    def post(self):
        have_error = False

        next_url = str(self.request.get('next_url'))
        if not next_url or next_url.startswith('/login'):
            next_url = '/'

        self.username = self.request.get('username')
        self.password = self.request.get('password')
        self.verify = self.request.get('verify')
        self.email = self.request.get('email')

        params = dict(username=self.username, email=self.email)

        if not utils.valid_username(self.username):
            params['error_username'] = "******"
            have_error = True

        if not utils.valid_password(self.password):
            params['error_password'] = "******"
            have_error = True
        elif self.password != self.verify:
            params['error_verify'] = "Your passwords didn't match."
            have_error = True

        if not utils.valid_email(self.email):
            params['error_email'] = "That's not a valid email."
            have_error = True

        if have_error:
            self.render('signup-form.html', **params)
        else:
            #make sure the user doesn't already exist
            u = data.User.by_name(self.username)
            if u:
                msg = 'That user already exists.'
                self.render('signup-form.html', error_username=msg)
            else:
                u = data.User.register(self.username, self.password,
                                       self.email)
                u.put()

                self.login(u)
                self.redirect(next_url)
Пример #4
0
    def post(self):
        have_error = False
        
        next_url = str(self.request.get('next_url'))
        if not next_url or next_url.startswith('/login'):
            next_url = '/'
        
        self.username = self.request.get('username')
        self.password = self.request.get('password')
        self.verify = self.request.get('verify')
        self.email = self.request.get('email')

        params = dict(username = self.username,
                      email = self.email)

        if not utils.valid_username(self.username):
            params['error_username'] = "******"
            have_error = True

        if not utils.valid_password(self.password):
            params['error_password'] = "******"
            have_error = True
        elif self.password != self.verify:
            params['error_verify'] = "Your passwords didn't match."
            have_error = True

        if not utils.valid_email(self.email):
            params['error_email'] = "That's not a valid email."
            have_error = True

        if have_error:
            self.render('signup-form.html', **params)
        else:           
            #make sure the user doesn't already exist
            u = data.User.by_name(self.username)
            if u:
                msg = 'That user already exists.'
                self.render('signup-form.html', error_username = msg)
            else:
                u = data.User.register(self.username, self.password, self.email)
                u.put()

                self.login(u)
                self.redirect(next_url)
Пример #5
0
	def post(self):
		referer = self.request.referer
		has_error = False
		username = self.request.get("username")
		password = self.request.get("password")
		password_verify = self.request.get("verify")
		email = self.request.get("email")

		params=dict(username=username, email=email)

		if not valid_user(username):
			params['error_username'] = "******"
			has_error = True

		if not valid_password(password):
			params['error_password'] = "******"
			has_error =True
		
		if password_verify != password:
			params['error_verify'] = "Your passwords do not match."
			has_error =True
		
		if not valid_email(email):
			params['error_email'] = "Something seems to be wrong. Check your email address."
			has_error = True
			


		if has_error == True:
			self.render("signup.html", **params)
		else:
			if memcache_user(username = username) == None:
				u = USERS.register(username,password,email)
				u.put()
				memcache_user(update = True)
				self.set_secure_cookie('uid',str(u.key().id()))

				self.redirect("/")
			else:
				params['error_username'] = "******"
				self.render("signup.html", **params)
Пример #6
0
    def post(self):
        error_flag = False      

        username = self.request.get('username')
        password = self.request.get('password')
        verify = self.request.get('verify')
        email = self.request.get('email')

        args = dict(username = username)
        
        #Double quotes are used when ' is present to avoid escaping.
        if not utils.valid_username(username):
            args['error_name'] = "That's not a valid username."
            error_flag = True
        dbo = userdb.User.all().filter('username', username)
        if dbo.get():
            args['error_name'] = 'The user already exists.'
            error_flag = True
        if not utils.valid_password(password):
            args['error_pass'] = "******"
            error_flag = True
        if not password == verify:
            args['error_verify'] = "Your passwords didn't match."
            error_flag = True
        if email != '' and not utils.valid_email(email):
            args['error_email'] = "That's not a valid email."
            error_flag = True

        if error_flag:
            self.render('signup.html', **args)
        else:
            args['password'] = utils.make_pw_hash(username, password)
            if email:
                args['email'] = email
            
            user = userdb.User(**args)
            user.put()

            self.login(user)
            self.redirect("/")
Пример #7
0
    def post(self):
        username = self.request.get('username')
        password = self.request.get('password')
        password2 = self.request.get('verify')
        email = self.request.get('email')
        errors = 0

        params = dict(username=username, email=email)

        # form input validation
        if not utils.valid_username(username):
            params['username_error'] = "That's not a valid username."
            errors += 1
        if not utils.valid_password(password):
            params['password_error'] = "That's not a valid password."
            errors += 1
        if not utils.password_match(password, password2):
            params['password_match_error'] = "Passwords do not match."
            errors += 1
        if email and not utils.valid_email(email):
            params['email_error'] = "That's not a valid email."
            errors += 1

        # check if user exists already
        u = query.get_user(username)
        if u:
            params['username_error'] = "User already exists"
            errors += 1

        if errors > 0:
            self.render('signup.html', **params)
        else:
            pw_hash = utils.make_pw_hash(username, password)
            u = query.create_user(username, pw_hash, email)

            # add cookie
            self.login(u)

            self.redirect('/')
Пример #8
0
 def post(self):
     username = self.request.get('username')
     password = self.request.get('password')
     verify = self.request.get('verify')
     email = self.request.get('email')
     usrerror = pwderror = verifyerror = emailerror = ""
     usr = User()
     if not valid_username(username):
         usrerror = "Invalid Username!"
     if not valid_password(password):
         pwderror = "invalid Password!"
     if not valid_email(email) and email != '':
         emailerror = 'Invalid Email!'
     if password != verify:
         verifyerror = "Passwords don't match!"
     if usr.by_name(username):
         usrerror= "Username already in use!"
     if usrerror or pwderror or verifyerror or emailerror:
         self.formpost(username, usrerror, pwderror, verifyerror, email, emailerror)
         return None
     else:
         usr.new(username, password, email)
         self.set_user_cookie(username)
         self.redirect("/")