Пример #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
    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')
Пример #3
0
 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')
Пример #4
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')
Пример #5
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)
Пример #6
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)
Пример #7
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))