Esempio n. 1
0
def register():
    if current_user.is_authenticated:
        redirect(url_for('main'))
    title = "Register"
    meta_description = "DJs, Live Musicians and Booking Agents are welcome to use this tool." \
                       " You can build nice PDF Riders for free, but you have to Register."
    form = RegistrationForm()
    if request.method == "GET":
        flash(
            'You are probably going to rebuild the document multiple times,'
            ' so I have to store your data somehow. It is not used anywhere and you will have an opportunity'
            ' to completely delete yourself after you are done.', 'info')
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = User(username=form.username.data,
                    email=form.email.data,
                    password=hashed_password)
        db.session.add(user)
        db.session.commit()
        login_user(user, remember=True)
        flash(f'User {user} created', 'success')
        return redirect(url_for('main'))
    return render_template('register.html',
                           title=title,
                           form=form,
                           meta_description=meta_description)
Esempio n. 2
0
def register():
    error = None
    #
    # if User.query.filter_by(email=request.form['email']).count()==0:
    #     user = User(
    #         email=request.form["email"],
    #         username=request.form["username"],
    #         password=request.form["password"],
    #         register_time=datetime.utcnow()
    #     )
    #     db.session.add(user)
    #     db.session.commit()
    #     return redirect(url_for('auth.login'))
    # else:
    #     return jsonify({'error':'email already been use!'})

    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data,
                    register_time=datetime.utcnow())
        db.session.add(user)
        db.session.commit()
        flash('You can now login.')
        return redirect(url_for('main.login'))
    return render_template('auth/register.html', form=form)
Esempio n. 3
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = User(username=form.username.data, password=hashed_password)
        db.session.add(user)
        db.session.commit()
        flash('Account created!')
        return redirect(url_for('login'))
    return render_template('register.html', title='Register', form=form)
Esempio n. 4
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('Congratulations, you are now a registered user!')
        return redirect(url_for('login'))
    return render_template('register.html', title='Register', form=form)
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        # Connected the registration page to database
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = User(username=form.username.data,
                    email=form.email.data,
                    password=hashed_password)
        db.session.add(user)
        db.session.commit()
        flash('Your account has been created! You are now able to log in',
              'success')
        return redirect(url_for('login'))
    return render_template('register.html', title='Register', form=form)
Esempio n. 6
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = User(username=form.username.data,
                    email=form.email.data,
                    password=hashed_password)
        db.session.add(user)
        db.session.commit()
        flash(f'Your account has been created, you can now Login!', 'success')
        return redirect(url_for('login'))
    return render_template('register.html', title='Register', form=form)
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        flash(f'Account created for {form.username.data}!', 'success')
        return redirect(url_for('home'))
    return render_template('register.html', title='Register', form=form)