Esempio n. 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)
Esempio n. 2
0
def dashboard():
    # 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=form.password.data)
        # db.session.add(user)
        # db.session.commit()
        flash('Your Security is now our Responsibility !', 'success')
        return redirect(url_for('home'))
        # return redirect(url_for('home'))
    return render_template('dashboard.html', title='Dashboard', form=form)
Esempio n. 3
0
    def post(self, request):
        form = RegistrationForm(request.POST, request.FILES)
        if form.is_valid():
            user = form.save(True)
            form.save_m2m()
            return redirect(reverse('security:login'))

        return render(request, 'security/registration.html', {'form': form})
Esempio n. 4
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)
Esempio n. 5
0
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)