예제 #1
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(email = form.email.data, username = form.username.data, password = form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('Thanks for registration')
        return redirect(url_for('users.login'))
    return render_template('register.html', form = form)
예제 #2
0
def register():
    form = RegistrationForm()
    # Validate the form
    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()
        flash("Thanks for registering! Now you can login")
        return redirect(url_for("users.login"))
    # For GET requests
    return render_template("register.html", form=form)
예제 #3
0
def register():
    form = RegistrationForm()

    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        # about pass_confirm, the form in the form.py itself taking care of it.
        db.session.add(user)
        db.session.commit()

        flash('Thanks for registering! Now you can login!')
        return redirect(url_for('users.login'))

    return render_template('register.html', form=form)
예제 #4
0
def register():
    form = RegistrationForm()
    print("in register form")
    if form.validate_on_submit():
        print("in validate on submit")
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        print("user: "******"db: ", db)
        db.session.commit()
        flash("Thanks for registration!")
        return redirect(url_for('users.login'))
    return render_template('register.html', form=form)
예제 #5
0
def register():
    form = RegistrationForm()  #instance of the form we created

    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        #if validated on submit we create our user based on info provided

        db.session.add(user)
        db.session.commit()
        flash('Thanks for registering! Now you can login!'
              )  #pointless flash, too quick
        return redirect(url_for('users.login'))
    return render_template('register.html', form=form)
예제 #6
0
def register():
    form = RegistrationForm()

    if form.validate_on_submit():
        # create new user
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        # add to the db
        db.session.add(User)
        db.session.commit()
        # redirect to users login
        flash("Thanks for registration.")
        return redirect(url_for('users.login'))
    # if it is not a POST request just show the form
    return render_template('register.html', form=form)
예제 #7
0
def register():
    form = SignupForm()

    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user is None:
            user = User(email=form.email.data,
                        username=form.username.data,
                        password=form.password.data)
            db.session.add(user)
            db.session.commit()

            flash('Successfully Signed Up, check your mail(including spam folder) to confirm your account', 'alert-success')
        else:
            flash('User already Exists', 'alert-warning')
        return redirect(url_for('users.login'))

    return render_template ('signup.html', form=form)
예제 #8
0
def register():
    form = RegistrationForm()
    print("*****************************")
    print(form)
    print(form.validate_on_submit())
    if form.validate_on_submit():
        print(
            "Heyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
        )
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('Thanks for registration')
        values = User.query.all()
        print(values)
        return redirect(url_for('users.login'))
    return render_template('register.html', form=form)
def register():
    if current_user.is_authenticated:
        logout_user()
    form = RegistrationForm()
    if form.validate_on_submit():
        check_email = form.check_email(form.email)
        check_username = form.check_username(form.username)

        if check_email and check_username:
            user = User(email=form.email.data,
                        username=form.username.data,
                        password=form.password.data)

            db.session.add(user)
            db.session.commit()
            flash('Thanks for registering! Now you can login!')
            return redirect(url_for('users.login'))
    elif request.method == 'POST':
        for key in form.errors.keys():
            flash(form.errors[key][0])
            print(form.errors[key][0])
    return render_template('register.html', form=form)
예제 #10
0
    def test_create_user(self):
        user = User('*****@*****.**', 'testusername', 'testpassword')

        self.assertEqual('*****@*****.**', user.email)
        self.assertEqual('testusername', user.username)
        self.assertTrue(user.check_password('testpassword'))