def register(): if g.user.is_authenticated(): flash("You are already registered.") return redirect(url_for('user_thanks', username = g.user.username)) form = RegisterForm() if form.validate_on_submit(): user = User(password = form.new_password.data, username = form.username.data) db.session.add(user) db.session.commit() profile = UserProfile(user_id = user.id, name = form.name.data) db.session.add(profile) email = form.registered_email if email != None: email.is_primary = True email.user_id = user.id else: email = Email(email = form.email.data, is_primary = True, user_id = user.id) db.session.add(email) follow = Follow(user.id, user.id) db.session.add(follow) db.session.commit() login_user(user) emails.register(email) return redirect(url_for('user_thanks', username = g.user.username)) return render_template('users/register.html', form = form, title = 'Register')
def register(): """Register new user.""" form = RegisterForm(request.form, csrf_enabled=False) if form.validate_on_submit(): User.create(username=form.username.data, email=form.email.data, password=form.password.data, active=True) flash('Thank you for registering. You can now log in.', 'success') return redirect(url_for('public.home')) else: flash_errors(form) return render_template('public/register.html', form=form)
def register(): form = RegisterForm(request.form) if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data, password=form.password.data) db.session.add(user) db.session.commit() login_user(user) flash('Thank you for registering.', 'success') return redirect(url_for("main.home")) return render_template('user/register.html', form=form)
def register(): form = RegisterForm(request.form, csrf_enabled=False) if form.validate_on_submit(): new_user = User.create(username=form.username.data, email=form.email.data, password=form.password.data, active=True) flash("Thank you for registering. You can now log in.", 'success') return redirect(url_for('public.home')) else: flash_errors(form) return render_template('public/register.html', form=form)
def register(): form = RegisterForm(request.form) if form.validate_on_submit(): user = User(nickname=form.nickname.data, email=form.email.data, password=generate_password_hash(form.password.data)) db.session.add(user) db.session.commit() session['user_id'] = user.id flash('Thanks for registering') return redirect(url_for('general.main')) return redirect(url_for('general.main'))
def register(): form = RegisterForm() if form.validate_on_submit(): print("a") User.create_user( username=form.username.data, email=form.email.data, password=form.password.data, ) flash("You have registered") return redirect(url_for(".index")) return render_template("register.html", form=form)
def register(): """Register new user.""" form = RegisterForm(request.form) if form.validate_on_submit(): User.create(id=time.time(), username=form.username.data, email=form.email.data, password=form.password.data, active=True) flash('Thank you for registering. You can now log in.', 'success') return redirect(url_for('public.home')) else: flash_errors(form) return render_template('public/register.html', form=form)
def register(): """Register new user.""" form = RegisterForm(request.form) if form.validate_on_submit(): User.create( username=form.username.data, email=form.email.data, password=form.password.data, active=True, ) flash("Thank you for registering. You can now log in.", "success") return redirect(url_for("public.home")) else: flash_errors(form) return render_template("public/register.html", form=form)
def signup(): form = RegisterForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') new_user = User(name=form.username.data, email=form.email.data, password=hashed_password) user = User.query.filter_by(email=form.email.data).first() if user: flash('User already exists') return redirect(url_for('auth.signup')) db.session.add(new_user) db.session.commit() return redirect(url_for('auth.login')) return render_template('signup.html', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = RegisterForm() if request.method == "POST": print("request POST") if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(email=form.email.data, first=form.first.data, last=form.last.data, hashed_password=hashed_password) db.session.add(user) db.session.commit() flash(f'User {user.full_name} registered.') return redirect(url_for('user.login')) return render_template('register.html', form=form)
def register(): ''' Registration Form ''' form = RegisterForm(request.form) if form.validate_on_submit(): # create an user instance not yet stored in the database user = User(name=form.name.data, email=form.email.data, \ password=generate_password_hash(form.password.data)) # Insert the record in our database and commit it db.session.add(user) db.session.commit() # Log the user in, as he now has an id session['user_id'] = user.id # flash will display a message to the user flash('Thanks for registering') # redirect user to the 'home' method of the user module. return redirect(url_for('user.home')) return render_template('user/register.html', form=form)
def register(): ''' Registration Form ''' form = RegisterForm(request.form) if form.validate_on_submit(): # create an user instance not yet stored in the database user = User(name=form.name.data, email=form.email.data, \ password=generate_password_hash(form.password.data)) # Insert the record in our database and commit it db.session.add(user) db.session.commit() # Log the user in, as he now has an id session['user_id'] = user.id # flash will display a message to the user flash('Thanks for registering') # redirect user to the 'home' method of the user module. return redirect(url_for('user.home')) return render_template('user/register.html', form=form)
def register(): form = RegisterForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode("utf-8") event = events.query.filter_by(id=form.quiz.data).first() user_login = users( email=form.email.data, name=form.name.data, clgname=form.clgname.data, phno=str(form.phno.data), password=hashed_password, quiz_name=form.quiz.data, timeleft=event.time, ) try: db.session.add(user_login) db.session.commit() flash("Signed up successfully.") next = request.args.get("next") socketio.emit( "stats_updated", { "user_id": user_login.user_id, "name": user_login.name, "phno": user_login.phno, "clgname": user_login.clgname, "score": user_login.score, }, namespace="/leaderboard/{}".format(event.event_name), ) return redirect(next or url_for("user.login")) except Exception as e: print(e) db.session.rollback() else: print(form.errors) return render_template("register.html", form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('main.index')) form_register = RegisterForm() form_login = LoginForm() if form_register.validate_on_submit(): hash_password = bcrypt.generate_password_hash( form_register.password.data) user = User(name=form_register.name.data, username=form_register.username.data, password=hash_password) db.session.add(user) db.session.commit() flash("%s your account has been created!" % (form_register.name.data), 'success') return redirect(url_for('main.index')) else: flash( 'Unsuccessful registraition. Please check information entered is corect.', 'danger') return render_template('user/register.html', form_register=form_register, form_login=form_login)