INNER CODE UNIT · Python

register

metafy-social/python-scripts · scripts/Authentication System using Flask/main.py:80

def register():
    if current_user.is_authenticated:
        return redirect(url_for('dashboard'))
    form = RegistrationForm()

    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(form.password.data)
        new_user = User(username=form.username.data, password=hashed_password)
        db.session.add(new_user)
        db.session.commit()
        return redirect(url_for('login'))

    return render_template('register.html', form=form)

if __name__ == '__main__':
    app.run(debug=True)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…