コード例 #1
0
ファイル: blog.py プロジェクト: anjiannian/Udacity
    def post(self):
        username = self.request.get('username')
        self.params['username'] = username
        password = self.request.get('password')
        verify = self.request.get('verify')
        email = self.request.get('email')
        self.params['email'] = email
        user = User.all()
        user.filter('username ='******'username_error'] = 'That is not a valid username'
        elif invalid_user:
            self.params['username_error'] = 'This name has been taken'
        else:
            self.params['username_error'] = ''

        if self.valid_password(password):
            self.params['password_error'] = ''
        else:
            self.params['password_error'] = 'That is not a valid password!'

        if verify == password:
            self.params['verify_error'] = ''
        else:
            self.params['verify_error'] = 'Your passwords did not match!'

        if self.valid_email(email):
            self.params['email_error'] = ''
        else:
            self.params['email_error'] = 'That is not a valid email!'

        if not invalid_user and self.valid_username(username) \
            and self.valid_password(password) and self.valid_email(email) \
            and verify == password:

            pwhash = au.make_pw_hash(username, password)
            new = User(username=username, password=pwhash, email=email)
            new.put()
            self.response.headers.add_header('Set-Cookie', 'user=%s; Path=/' % str(username))
            self.response.headers.add_header('Set-Cookie', 'pw=%s; Path=/' % str(pwhash))
            sleep(0.5)
            self.redirect('/blog/welcome')
        else:
            self.render('signup.html', **self.params)
コード例 #2
0
ファイル: blog.py プロジェクト: anjiannian/Udacity
    def get(self):
        username = self.request.cookies.get('user')
        if not username:
            self.redirect('/blog/signup')
        else:
            password = self.request.cookies.get('pw')

            user = User.all()
            user.filter('username ='******'Welcome, %s' % username)
                else:
                    self.response.write('逗逼再见!')
コード例 #3
0
ファイル: blog.py プロジェクト: anjiannian/Udacity
 def post(self):
     username = self.request.get('username')
     self.params['username'] = username
     password = self.request.get('password')
     user = User.all()
     user.filter('username ='******'Set-Cookie', 'user=%s; Path=/' % str(username))
             self.response.headers.add_header('Set-Cookie', 'pw=%s; Path=/' % str(u.password))
             sleep(0.5)
             self.redirect('/blog/welcome')
         else:
             self.params['error'] = 'Invalid Login!'
             self.render('login.html', **self.params)
コード例 #4
0
ファイル: blog.py プロジェクト: anjiannian/Udacity
    def get(self):
        username = self.request.cookies.get('user')
        if not username:
            self.render('login.html', **self.params)
        else:
            password = self.request.cookies.get('pw')

            user = User.all()
            user.filter('username ='******'/blog/welcome')
                else:
                    self.params['error'] = '逗逼再见!'
                    self.render('login.html', **self.params)