コード例 #1
0
 def register(cls,
              name,
              pw,
              email='*****@*****.**'):
     pw_hash = make_pw_hash(name, pw)
     return User(parent=users_key(),
                 username=name,
                 password=pw_hash,
                 email=email)
コード例 #2
0
    def post(self):
        username = self.request.get('username')
        password = self.request.get('password')
        verify = self.request.get('verify')
        email = self.request.get('email')

        valid_username = validate_username(username)
        valid_password = validate_password(password) and validate_password(
            verify)
        mismatch_passwords = password == verify
        valid_email = validate_email(email)

        #query for user data to check for duplicate users in db

        q = Users.all()
        q.filter("username ="******"That's not a valid username."

            if not valid_password:
                error_password = "******"
            elif not mismatch_passwords:
                error_mismatch_passwords = "Your passwords didn't match."

            if (not valid_email) and email != '':
                error_email = "That's not a valid email."

            self.render('signup.html',
                        error_username=error_username,
                        error_password=error_password,
                        error_mismatch_passwords=error_mismatch_passwords,
                        error_email=error_email,
                        username=username,
                        email=email)

        else:
            #hash password
            hashed_password = make_pw_hash(username, password)

            if email:
                recently_added_user = Users(username=username,
                                            password=hashed_password,
                                            email=email)
            else:
                recently_added_user = Users(username=username,
                                            password=hashed_password,
                                            email='*****@*****.**')
            recently_added_user.put()

            #make cookie hash
            user_id = str(recently_added_user.key().id())
            cookie_data = make_user_cookie_hash(user_id, username)

            self.response.headers.add_header(
                'Set-Cookie', 'user_id=%s; Path=/blog' % cookie_data)
            self.redirect('/blog/welcome')
コード例 #3
0
	def post(self):
		username = self.request.get('username')
		password = self.request.get('password')
		verify = self.request.get('verify')
		email = self.request.get('email')

		valid_username = validate_username(username)
		valid_password = validate_password(password) and validate_password(verify)
		mismatch_passwords = password == verify
		valid_email = validate_email(email)

		#query for user data to check for duplicate users in db
		
		q = Users.all()
		q.filter("username ="******"That's not a valid username."

			if not valid_password:
				error_password = "******"
			elif not mismatch_passwords:
				error_mismatch_passwords = "Your passwords didn't match."

			if (not valid_email) and email != '':
				error_email = "That's not a valid email."

			self.render('signup.html', error_username = error_username,
										error_password = error_password,
										error_mismatch_passwords = error_mismatch_passwords,
										error_email = error_email,
										username = username,
										email = email)

		else:
			#hash password
			hashed_password = make_pw_hash(username, password)

			if email:
				recently_added_user = Users(username = username, 
									password = hashed_password, 
									email = email)
			else:
				recently_added_user = Users(username = username, 
									password = hashed_password, 
									email = '*****@*****.**')
			recently_added_user.put()

			#make cookie hash
			user_id = str(recently_added_user.key().id())
			cookie_data = make_user_cookie_hash(user_id,  username)
			
			self.response.headers.add_header('Set-Cookie', 
									'user_id=%s; Path=/blog' % cookie_data)
			self.redirect('/blog/welcome')
コード例 #4
0
	def register(cls, name, pw, email = '*****@*****.**'):
		pw_hash = make_pw_hash(name, pw)
		return User(parent = users_key(),
					username = name,
					password = pw_hash,
					email = email)