示例#1
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, type_force=form.type_force.data, units=form.units.data, password=form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('Your account has been created! You are now able to login', 'success')
        return redirect(url_for('login'))
        # return redirect(url_for('home'))
    return render_template('register.html', title='Register', form=form)
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = Register.Form()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = Admin(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)
示例#3
0
def signup():
    if current_user.is_authenticated:
        return redirect(url_for('login'))
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = User(name=form.name.data,
                    username=form.username.data,
                    email=form.email.data,
                    password=hashed_password)
        db.session.add(user)
        db.session.commit()
        port_main = Portfolio_main(username=form.username.data)
        db.session.add(port_main)
        db.session.commit()
        # port_second = Portfolio_second(username=form.username.data)
        # db.session.add(port_second)
        # db.session.commit()
        flash(
            f'Account created for {form.username.data}, Now you can login to access your account!',
            "success")
        return redirect(url_for('login'))
    return render_template('signup.html', form=form)
示例#4
0
 def hash_password(self):
     """Check password."""
     self.password = bcrypt.generate_password_hash(
         self.password).decode('UTF-8')