def register(request): form = RegistrationForm(request.POST or None) if form.is_valid(): user = form.save(commit=False) password = form.cleaned_data.get('password2') user.set_password(password) user.save() return redirect("/login") return render(request, 'body/register.html', {'form': form})
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(): 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('You have registered successfully!') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
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('Twoje konto zostało utworzone! Możesz się zalogować', 'success') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): hased_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(username=form.username.data, email=form.email.data, password=hased_password) db.session.add(user) db.session.commit() flash(f'Account Created for {form.username.data}!', 'green') return redirect(url_for('login')) return render_template('auth/register.html', title="Register", form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): hashed_pw = bcrypt.generate_password_hash(form.password.data).decode('utf-8') user_collection.insert_one({ 'username': form.username.data, 'password': hashed_pw, 'email': form.email.data, 'image': 'default.jpeg', 'posts': [] }) flash(f'Your Account Has Been Createad! You Can Login Now', 'success') return redirect(url_for('login')) return render_template('register.html', title = 'Register', form = form)
def register(): if current_user.is_authenticated: flash('You already have an account', 'success') 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('Your account has been created! You can now log in', 'success') current_user.username = form.username.data current_user.email = form.email.data return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)