示例#1
0
    def post(self):
        errorUser = errorPassword = errorVerify = errorEmail = ''

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

        if not (valid_username(username) and valid_password(password) and
                (password == verify) and valid_email(email)):
            if not valid_username(username):
                errorUser = '******'s not a valid username.'
            if not valid_password(password):
                errorPassword = '******'t a valid password.'
            if password != verify:
                errorVerify = 'Your passwords didn\'t match.'
            if not valid_email(email):
                errorEmail = 'That\'s not a valid email.'

            password = ''
            verify = ''
            self.write_form(username, password, verify, email, errorUser,
                            errorPassword, errorVerify, errorEmail)
        else:
            self.redirect("/unit2/welcome?username=" + str(username))
示例#2
0
文件: blog.py 项目: jcerjak/mfnblog
    def post(self):
        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)
        we_have_error = False
        if not tools.valid_username(self.username):
            we_have_error = True
            params['error_username'] = "******"
        if not tools.valid_password(self.password):
            we_have_error = True
            params['error_password'] = "******"
        if not tools.valid_verify(self.password, self.verify):
            we_have_error = True
            params['error_verify'] = "Passwords do not match!"
        #if not tools.valid_email(self.email):
        #    we_have_error = True
        #    params['error_email'] = "Invalid email!"
        if we_have_error:
            self.render("signup.html", **params)
        else:
            #make sure the user doesn't already exist
            u = database_models.User.by_name(self.username)
            if u:
                params['error_username'] = '******'
                self.render('signup.html', **params)
            else:
                u = database_models.User.register(
                    self.username, self.password, self.email)
                u.put()

                self.login(u)
                self.redirect('/welcome')
示例#3
0
    def post(self):
        """
        Post method is called when user signs up for blog.
        Validation functions are implemented in tools.py.
        After successful login the user is redirected to a "welcome" page.
        """
        username = self.request.get('username')
        password = self.request.get('password')
        verify = self.request.get('verify')
        email = self.request.get('email')

        if not username:
            return self.render('signup.html',
                               username=username,
                               email=email,
                               error_username="******")
        elif not tools.valid_username(username):
            return self.render('signup.html',
                               username=username,
                               email=email,
                               error_username="******"
                               "required specifications")
        elif not password:
            return self.render('signup.html',
                               username=username,
                               email=email,
                               error_password="******")
        elif not tools.valid_password(password):
            return self.render('signup.html',
                               username=username,
                               email=email,
                               error_password="******"
                               "required specifications")
        elif not password == verify:  # invalid user data
            return self.render('signup.html',
                               username=username,
                               email=email,
                               error_password="******")
        elif not tools.valid_email(email):
            return self.render('signup.html',
                               username=username,
                               error_password="******")
        else:  # valid user data
            # make sure the user doesn't already exist
            u = User.User.by_name(username)
            if u:
                msg = 'That user already exists.'
                return self.render('signup.html', error_username=msg)
            else:
                u = User.User.register(username, password, email)
                u.put()

                self.login(u)
                return self.redirect('/blog/welcome')
示例#4
0
 def post(self):
     errorUser = errorPassword = errorVerify = errorEmail = ''
     
     username = self.request.get('username')
     password = self.request.get('password')
     verify  = self.request.get('verify')
     email = self.request.get('email')
     
     if not (valid_username(username) and valid_password(password) and (password == verify) and valid_email(email)):
         if not valid_username(username):
             errorUser = '******'s not a valid username.'
         if not valid_password(password):
             errorPassword = '******'t a valid password.'
         if password != verify:
             errorVerify = 'Your passwords didn\'t match.'
         if not valid_email(email):
             errorEmail = 'That\'s not a valid email.'
             
         password = ''
         verify = ''
         self.write_form(username,password,verify,email,errorUser,errorPassword,errorVerify,errorEmail)
     else:
         self.redirect("/unit2/welcome?username="+str(username))
示例#5
0
文件: main.py 项目: ab7/sax-lessons
 def post(self):
     have_error = False
     name = self.request.get('name')
     user_name = self.request.get('username')
     user_pw = self.request.get('password')
     verify = self.request.get('verify')
     user_email = self.request.get('email')
     drive_link = self.request.get('drive')
     params = dict(name = name,
                   username = user_name,
                   email = user_email,
                   drive = drive_link,
                   button_text = "Create")
     if not name:
         params['name_error']= "Please enter a name!"
         have_error = True
     if not tools.valid_username(user_name):
         params['username_error'] = "That's not a valid name!"
         have_error = True
     if ds.Students.by_user(user_name).get():
         params['name_error'] = "That user already exists!"
         have_error = True
     if not tools.valid_password(user_pw):
         params['password_error'] = "That's not a valid password!"
         have_error = True
     elif user_pw != verify:
         params['verify_error'] = "Passwords do not match!"
         have_error = True
     if not tools.valid_email(user_email):
         params['email_error'] = "That's not a valid email!"
         have_error = True
     if not drive_link:
         params['drive_error']= "Please enter Google Drive link!"
         have_error = True
     if have_error:
         self.render('addstudent.html', **params)
     else:
         hashed_pw = tools.password_protect(user_pw)
         user = ds.write_user(
                         user = user_name,
                         password = hashed_pw,
                         email = user_email,
                         name = name,
                         drive_link = drive_link
                         )
         self.redirect('/admin')
示例#6
0
    def post(self):
        """
        Post method is called when user signs up for blog.
        Validation functions are implemented in tools.py.
        After successful login the user is redirected to a "welcome" page.
        """
        username = self.request.get('username')
        password = self.request.get('password')
        verify = self.request.get('verify')
        email = self.request.get('email')

        if not username:
            return self.render('signup.html', username=username, email=email,
                               error_username="******")
        elif not tools.valid_username(username):
            return self.render('signup.html', username=username, email=email,
                               error_username="******"
                                       "required specifications")
        elif not password:
            return self.render('signup.html', username=username, email=email,
                               error_password="******")
        elif not tools.valid_password(password):
            return self.render('signup.html', username=username, email=email,
                               error_password="******"
                                       "required specifications")
        elif not password == verify:  # invalid user data
            return self.render('signup.html', username=username, email=email,
                               error_password="******")
        elif not tools.valid_email(email):
            return self.render('signup.html', username=username,
                               error_password="******")
        else:  # valid user data
            # make sure the user doesn't already exist
            u = User.User.by_name(username)
            if u:
                msg = 'That user already exists.'
                return self.render('signup.html', error_username=msg)
            else:
                u = User.User.register(username, password, email)
                u.put()

                self.login(u)
                return self.redirect('/blog/welcome')
示例#7
0
    def post(self, sRedirectPath=''):
        errorUser = errorPassword = errorVerify = errorEmail = ''

        username = self.request.get('username')
        password = self.request.get('password')
        verify = self.request.get('verify')
        email = self.request.get('email')
        has_error = False
        if not valid_username(username):
            errorUser = '******'s not a valid username.'
            has_error = True
        if not valid_password(password):
            errorPassword = '******'t a valid password.'
            has_error = True
        elif password != verify:
            errorVerify = 'Your passwords didn\'t match.'
            has_error = True

        if not valid_email(email):
            errorEmail = 'That\'s not a valid email.'
            has_error = True
        if has_error:
            password = ''
            verify = ''
            self.write_form(username, password, verify, email, errorUser,
                            errorPassword, errorVerify, errorEmail)
        else:
            u = User.by_name(username)
            if u:
                errorUser = '******'
                self.write_form(username, password, verify, email, errorUser,
                                errorPassword, errorVerify, errorEmail)
            else:
                u = User.register(username, password, email)
                u.put()
                cookie_val = make_secure_val(str(u.key().id()))
                self.response.headers.add_header(
                    'Set-Cookie', '%s=%s; Path=/' % ('user_id', cookie_val))
                self.redirect(sRedirectPath)
示例#8
0
    def post(self,sRedirectPath=''):
        errorUser = errorPassword = errorVerify = errorEmail = ''
        
        username = self.request.get('username')
        password = self.request.get('password')
        verify  = self.request.get('verify')
        email = self.request.get('email')
        has_error = False
        if not valid_username(username):
            errorUser = '******'s not a valid username.'
            has_error = True
        if not valid_password(password):
            errorPassword = '******'t a valid password.'
            has_error = True
        elif password != verify:
            errorVerify = 'Your passwords didn\'t match.'
            has_error = True

        if not valid_email(email):
            errorEmail = 'That\'s not a valid email.'
            has_error = True
        if has_error:
            password = ''
            verify = ''
            self.write_form(username,password,verify,email,errorUser,errorPassword,errorVerify,errorEmail)
        else:
            u = User.by_name(username)
            if u:
                errorUser = '******'
                self.write_form(username,password,verify,email,errorUser,errorPassword,errorVerify,errorEmail)
            else:
                 u = User.register(username,password,email)
                 u.put()
                 cookie_val = make_secure_val(str(u.key().id()))
                 self.response.headers.add_header(
                     'Set-Cookie',
                     '%s=%s; Path=/' % ('user_id', cookie_val))
                 self.redirect(sRedirectPath)