def register(): if current_user.is_authenticated: return redirect(url_for('main.index')) form = RegistrationForm() if form.validate_on_submit(): hashed_pw = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(username=form.username.data, email=form.email.data, password=hashed_pw, confirmed=False) db.session.add(user) db.session.commit() try: send_verification_email(user) flash("A verification email has been sent to your email id.", 'success') return redirect(url_for('users.login')) except: flash( "An error occured while sending email. Try again in a moment!", 'error') return redirect(url_for('users.login')) return render_template('register.html', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): user = User(email=form.email.data, username=form.username.data, password=form.password.data) unique_check = User.query.filter_by(email=form.email.data).first() if not unique_check: unique_check = User.query.filter_by( username=form.username.data).first() if unique_check: return redirect(url_for('users.register')) else: return redirect(url_for('users.register')) token = confirm.dumps(form.email.data, salt='salt.email.confirm') db.session.add(user) db.session.commit() flash('Thanks for registration!') msg = Message('Please confirm your email!', sender='*****@*****.**', recipients=[form.email.data]) link = url_for('users.confirmation', token=token, _external=True) msg.body = 'Congrats! You have been registered. Email confirmation link: {}'.format( link) mail.send(msg) return redirect(url_for('users.login')) return render_template('register.html', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = RegistrationForm() if form.validate_on_submit(): form.create_user() flash(f'Account created. You are now able to login!', 'success') return redirect(url_for('users.login')) return render_template('register.html', title='Register', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): user = User(email=form.email.data, username=form.username.data, password=form.password.data) db.session.add(user) db.session.commit() flash('Thanks for registering') return redirect(url_for('core.index')) return render_template('register.html', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): user = User(email=form.email.data, username=form.username.data, password=form.password.data) db.session.add(user) db.session.commit() flash('Registration Sucessful') return redirect(url_for('users.login')) return render_template('register.html', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('main.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 acoount has been created. You are now able to log in.', 'success') return redirect(url_for('users.login')) return render_template('register.html', title='Register', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for("main.home")) form = RegistrationForm() if form.validate_on_submit(): if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data) user.set_password(form.password.data) user.save() flash("User registered! Please Log in", "success") return redirect(url_for("users.login")) return render_template("users/register.html", title="Register", form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('main.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("註冊完成! 可以開始登入", "success") return redirect(url_for("users.login")) return render_template("register.html", form = form, title = "Register")
def register(): if current_user.is_authenticated: return redirect(url_for("main.home")) form = RegistrationForm() if request.method == 'POST': if form.validate_on_submit(): hashed_pass = bcrypt.generate_password_hash(form.password.data).decode('utf-8') user = User(username=form.username.data.title(), email=form.email.data, password=hashed_pass) db.session.add(user) db.session.commit() flash(f"Account created successfully! Now you can login", 'success') return redirect(url_for("users.login")) return render_template("register.html", title='Register', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): username = form.username.data email = form.email.data password = form.password.data user = User(username, email, password) db.session.add(user) db.session.commit() flash("Thanks for your registration!!") return redirect(url_for("users.login")) return render_template("register.html", form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): user = User(email=form.email.data, password=form.password.data) db.session.add(user) db.session.commit() flash("Registration Successful") return redirect(url_for("users.login")) return render_template("register.html", form=form)
def register(): if current_user.is_authenticated: return redirect(url_for("main.home")) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode() 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", category="success") return redirect(url_for("users.login")) return render_template("register.html", title="Register", form=form)
def index(): if current_user.is_authenticated: return redirect(url_for('users.account')) 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'Account created for {form.username.data}! You can now login', 'success') return redirect(url_for('users.login')) return render_template('index.html', title='Register', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('main.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('Account created, you can now login.', 'success') #second parameter is the category of the message return redirect(url_for('users.login')) return render_template('register.html', title='Register', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('main.index')) form = RegistrationForm() if form.validate_on_submit(): hashed_pw = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(username=form.username.data, email=form.email.data, password=hashed_pw) db.session.add(user) db.session.commit() flash(f'Account creato per {form.username.data}', 'success') return redirect(url_for('users.login')) return render_template('register.html', title="Registrazione", form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('main.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) user.save() flash( f'Account created for {form.username.data}. Then, you can login Now', 'success') return redirect(url_for('users.login')) return render_template('register.html', title='Register', form=form)
def register(): form = RegistrationForm() if current_user.is_authenticated: flash('You have already logged in!', 'info') return redirect(url_for('main.home')) if form.validate_on_submit(): user = registration_data(form) if user: flash( f'Account {user.username} been successfully created. You can Login', 'success') return redirect(url_for('users.login')) return render_template('register.htm', form=form, title='register')
def register(): if current_user.is_authenticated: return redirect(url_for('main.home')) # create form with validation in register html (flask_WTF) form = RegistrationForm() if form.validate_on_submit(): # use decode('utf-8') to decode to string hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(username=form.username.data.lower(), email=form.email.data.lower(), password=hashed_password) db.session.add(user) db.session.commit() flash(f'Account created for {form.username.data}!', 'success') return redirect(url_for('users.login')) return render_template('users/register.html', title='Register', form=form)
def register(): form = RegistrationForm() error = None; if request.method == 'POST' and form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user: error = "Email Already Exists" else: user = User(email=form.email.data, username=form.username.data, password=form.password.data) db.session.add(user) db.session.commit() flash('Thanks For Registration','regi_success') return redirect(url_for('users.login')) return render_template('register.html',form=form,error=error)
def register(): form = RegistrationForm() print(form.email.data) print(form.validate_on_submit()) if form.validate_on_submit(): user = User(email=form.email.data, username=form.username.data, password=form.password.data) db.session.add(user) db.session.commit() flash('Thanks for Registration!') return redirect(url_for("users.login")) return render_template("register.html", form=form)
def registration(): reg_form = RegistrationForm() if reg_form.validate_on_submit(): username = reg_form.username.data email = reg_form.email.data password = reg_form.password.data password_hash = generate_password_hash(password) user = User(username=username, email=email, password_hash=password_hash) db.session.add(user) db.session.commit() flash("Поздравляю! Теперь вы зарегистрированный пользователь.", "success") return redirect(url_for('users.login')) return render_template('auth/registration.html', form=reg_form)
def register(): # So the user doesn't go to register page when signed in if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): # hash the password hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8') # create user instance and add to db user = User(username=form.username.data, email=form.email.data, password=hashed_password) db.session.add(user) db.session.commit() # flash message can be parsed into html for frontend layout flash(f'Your account: {form.username.data} has been created!', 'success') return redirect(url_for('users.login')) return render_template('register.html', title='Register', form=form)
def register(): if current_user.is_authenticated: # .attribute comes from UserMixin class return redirect(url_for( 'main.home')) # so as logged user doesn't see those register&login form = RegistrationForm() if form.validate_on_submit(): # this func() triggers validate_funcs() hashed_pass = bcrypt.generate_password_hash( form.password.data).decode('utf-8') new_user = User(username=form.username.data, email=form.email.data, password=hashed_pass, country=form.country.data) db.session.add(new_user) db.session.commit() send_confirm_email(new_user) flash( f'Account for {form.username.data} \ has been created. Verify your account by the link sent to the email', 'success') return redirect(url_for('users.login')) return render_template('register.html', title='Registration', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): user = User(email=form.email.data, username=form.username.data, password=form.password.data, confirmed=False) db.session.add(user) db.session.commit() token = generate_confirmation_token(user.email) confirm_url = url_for('users.confirm_email', token=token, _external=True) html = render_template('user_confirm_mail.html', confirm_url=confirm_url) subject = "Please confirm your email" send_email(user.email, subject, html) flash('Thanks for registering! Now you can login!') return redirect(url_for('users.unconfirmed')) return render_template('register.html', form=form)