コード例 #1
0
ファイル: wikichimp.py プロジェクト: hadtien/wikichimp
    def post(self):
        username = self.request.get('username')
        password = self.request.get('password')
        verify = self.request.get('verify')
        email = self.request.get('email')
        uname_error, pwd_error, pwd_error_match, email_error, uname_exists = '', '', '', '', ''

        user_re = re.compile(r"^[a-zA-Z0-9_-]{3,20}$")
        pwd_re = re.compile(r"^.{3,20}$")
        email_re = re.compile(r"^[\S]+@[\S]+\.[\S]+$")
        if not user_re.match(username):
            uname_error = "That's not a valid username."
        if not pwd_re.match(password):
            pwd_error = "That wasn't a valid password."
        elif password != verify:
            pwd_error_match = "Your passwords didn't match."
        if email and not email_re.match(email):  # email optional
            email_error = "That's not a valid email."

        user = User(username=username, password_hash=utils.make_pw_hash(username, password))

        q = User.all()
        q.filter("username ="******"Username exists"
        if uname_error or pwd_error or pwd_error_match or email_error or uname_exists:
            self.render("signup.html", username_error=uname_error, password_error=pwd_error,
                        verify_error=pwd_error_match, email_error=email_error, usernam=username,
                        email=email, username_exists=uname_exists)
        else:
            user.put()
            self.response.headers.add_header('Set-Cookie', 'uname=%s;Path=/' % str(username))
            self.redirect("/")
コード例 #2
0
ファイル: wikichimp.py プロジェクト: hadtien/wikichimp
    def post(self):
        username = self.request.get('username')
        password = self.request.get('password')

        q = User.all()
        q.filter("username ="******"login.html", invalid_login="******")
            return
        user = q.get()
        if not utils.valid_pw(username, password, user.password_hash):
            self.render("login.html", invalid_login="******")
            return
        else:
            self.response.headers.add_header('Set-Cookie', 'uname=%s;Path=/' % str(username))
            self.redirect("/")