示例#1
0
def register():
    form = UserRegistrationForm()
    pprint (form)
    if form.validate_on_submit():
        app.logger.debug("""
            username:{username}\n
            password:{password}\n  
            email:{email}\n
            first_name:{first_name}\n
            last_name:{last_name}\n""".format(username=form.username.data, 
            password=form.password.data,
            email=form.email.data,
            first_name=form.first_name.data,
            last_name=form.last_name.data))
        user = models.User(username=form.username.data,
            password=form.password.data,
            email=form.email.data,
            first_name=form.first_name.data,
            last_name=form.last_name.data)
        user.save() #TODO: Exception handling
        return render_template('user-registration.html',
            form=form,
            user=user,
            registration='success')
    return render_template('base-bootstrap.html',
        web_content_marketing=web_content.marketing_content,
        web_content_ui=web_content.ui_elements,
        form=form,
        username='******')
def add_user():
    stringvalue=["Already Have an Account", "Sign in", "User", "Admin Singin", "admin_login",]
    form = UserRegistrationForm()
    if not form.validate_on_submit():
    	flash('please enter valid user details')
    else:
	    entrynumber = form.entryNumber.data
	    name = form.name.data
	    password = form.password.data
	    emailid = form.emailId.data
    if request.method == 'POST' and userNotAvailabe(entrynumber) and len(entrynumber)>4 and len(name) > 3 and len(password) > 7 and '@' in emailid and not pendingAvailable(entrynumber):
    	insertstmt = "insert into pending values ('{}', '{}', '{}', '{}',{},{},{});".format(entrynumber, name, password, emailid,0,0,0)
    	cursor.execute(insertstmt)
    	connection.commit()
    	flash("Please wait till confirmation")
    	return redirect(url_for('login_user'))
    elif request.method=='POST' and len(entrynumber) < 6:
    	flash('length of userid is too sort at least 7 char')
    elif request.method=='POST' and len(name) < 4:
    	flash('length of name is too sort')
    elif request.method=='POST' and len(password) < 8:
    	flash('Please enter at least 8 word password')
    elif request.method=='POST' and ('@' not in emailid):
    	flash('Please enter valid email id')
    elif request.method=='POST' and pendingAvailable(entrynumber):
    	flash("Already signup....Please wait till confirmation")
    elif request.method=='POST' and not userNotAvailabe(entrynumber):
    	flash("Userid Already taken please try different userid")

    return render_template('register.html',title='Register',form=form, stringvalue=stringvalue)
示例#3
0
def user_registration():
    form = UserRegistrationForm()
    if form.validate_on_submit():
        app.logger.debug("""
            username:{username}\n
            password:{password}\n  
            email:{email}\n
            first_name:{first_name}\n
            last_name:{last_name}\n""".format(username=form.username.data, 
            password=form.password.data,
            email=form.email.data,
            first_name=form.first_name.data,
            last_name=form.last_name.data))
        user = models.User(username=form.username.data,
            password=form.password.data,
            email=form.email.data,
            first_name=form.first_name.data,
            last_name=form.last_name.data)
        user.save() #TODO: Exception handling
        return render_template('user-registration.html',
            form=form,
            user=user,
            registration='success')
    return render_template('user-registration.html',
        form=form,
        registration='new')
示例#4
0
def user_registration():
    """User Registration Page"""
    form = UserRegistrationForm()
    if form.validate_on_submit():
        username = form.username.data
        password = form.password.data
        email = form.email.data
        first_name = form.first_name.data
        last_name = form.last_name.data
        zip_code = form.zip_code.data

        new_user = User.register(username, password, email, first_name,
                                 last_name, zip_code)
        db.session.add(new_user)
        try:
            db.session.commit()
        except IntegrityError:
            form.username.errors.append("Username is taken")
            return render_template('users/register.html', form=form)

        session["username"] = new_user.username  # Keeps user logged in
        flash(f"Welcome {first_name}, we successfully created your account!",
              "success")
        return redirect('/')
    else:
        return render_template('users/register.html', form=form)
 def post(self):
     form = UserRegistrationForm()
     if form.validate_on_submit():
         u = User()
         returnvalue = u.UserRegistration(form.username.data,
                                          form.email.data,
                                          form.password.data, 'U')
         if returnvalue:
             return make_response(render_template_string(returnvalue))
         return make_response(
             render_template_string(
                 "<p>There is Already An User With That Username or Email</p>"
                 "<small class='text-muted'><a href = '/register'>Register</a></small>"
             ))
示例#6
0
文件: picMe.py 项目: kp1732/picMe
def register():
    # check if user is logged in
    if "username" in session.keys():
        return redirect(url_for('home'))

    # create user reg form
    form = UserRegistrationForm()

    # if valid
    if form.validate_on_submit():

        # extract data from user registration form
        username = form.username.data
        password = form.password.data
        firstName = form.firstName.data
        lastName = form.lastName.data
        bio = form.biography.data

        # hash and salt plaintext password before insertion
        hashed_password = saltBae(password, salt)

        # try to register user
        try:
            query = 'INSERT INTO Person (username, password, firstName, lastName, bio, profilePicPath) VALUES ("{}", "{}","{}", "{}", "{}", "{}");'.format(
                username, hashed_password, firstName, lastName, bio,
                'default.png')
            queryFetch(query)
        except pymysql.err.IntegrityError:
            flash("Username already taken!, please try again.", 'danger')
            return redirect(url_for('register'))

        flash(
            "Account created successfully for {}, you may now login!".format(
                username), 'success')
        return redirect(url_for('login'))

    # if not valid just return to register page and flash warning
    return render_template('register.html', title='Register', form=form)
示例#7
0
def display_registration_form():
    form = UserRegistrationForm()

    if form.validate_on_submit():
        username = form.username.data
        password = form.password.data
        email = form.email.data
        first_name = form.first_name.data
        last_name = form.last_name.data
        new_user = User.register_new_user(username, password, email,
                                          first_name, last_name)
        db.session.add(new_user)
        try:
            db.session.commit()
        except IntegrityError:
            form.username.errors.append(
                'Username is taken, please choose a different one')
            return render_template('registration_form.html', form=form)
        flask.session['username'] = new_user.username
        flash('Welcome! Successfully Created Your Account!', "success")
        return redirect(f'/users/{username}')
    else:
        return render_template('registration_form.html', form=form)
示例#8
0
def register():
    form = UserRegistrationForm()
    print(f'Form errors: {form.errors}')

    if request.method == 'GET':
        return render_template('register.html', form=form)

    else:
        if form.validate_on_submit():
            user = User.create(
                form.password.data,
                username=form.username.data,
                last_name=form.last_name.data,
                first_name=form.first_name.data,
            )
            if user:
                session['user_id'] = user.id
                session['username'] = user.username
                return redirect(url_for('main'))

        flash(
            'Registration failed: this username is already taken or password do not match',
            'danger')
        return redirect(url_for('register'))
示例#9
0
def register():
    signup_form = UserRegistrationForm()
    alternative = {'label': 'Sign in', 'endpoint': 'signin'}
    if not signup_form.validate_on_submit():
        return render_template('bootstrap-pages/signup-page.html',
                               form=signup_form,
                               alternative=alternative,
                               title='Register')

    # When you get here, you're good. Now let's see if you already have an account
    user_details = request.form
    # Check the database for user presence
    exists, _ = info_check('users', 'email', user_details['email'])
    if exists:
        return redirect(url_for('signin'))

    user = {
        'name': user_details['name'],
        'email': user_details['email'],
        'username': user_details['username'],
        'password': user_details['password']
    }
    add_user(user)
    return redirect(url_for('signin'))
示例#10
0
def register():
    form = UserRegistrationForm()
    if form.validate_on_submit():
        flash(f'Account Created for {form.username.data}!', 'success')
        return redirect(url_for('home'))
    return render_template('register.html', form=form, title='Register')