예제 #1
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        new_user = User(email=form.email.data, password=hashed_password)
        db.session.add(new_user)
        db.session.commit()
        flash('Account created! You may now login.', 'success')
        return redirect(url_for('users.login'))
    return render_template('register.html', title='Register', form=form)
예제 #2
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    passowrd=form.password.data)

        db.session.add(user)
        db.session.commit()
        flash("Thanks for registering")
        return redirect(url_for('users.login'))
    return render_template('register.html', form=form)
예제 #3
0
def register():
	if current_user.is_authenticated:
		return redirect(url_for('home'))
	form = RegistrationForm()
	if form.validate_on_submit():
			hashed_passowrd = bcrypt.generate_password_hash(form.password.data).decode('utf-8')
			user = User(usertype=form.usertype.data, username=form.username.data, email=form.email.data, password=hashed_passowrd)
			db.session.add(user)
			db.session.commit()
			flash('Youer account now Creaated, Now You are login now', 'success')
			return redirect(url_for('main.home'))
	return render_template('register.html', title='Register', form=form)
예제 #4
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('primary.home'))

    form = RegistrationForm()
    if form.validate_on_submit():
        #hash the password they gave us
        hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8')
        #create a new instance of a user
        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 are now able to login.', 'success')
        return redirect(url_for('users.login'))
    return render_template('register.html', title='Register', form=form)
예제 #5
0
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 log in!', 'success')
        return redirect(url_for("users.login"))
    return render_template("register.html", form=form)
예제 #6
0
def register():
    if current_user.is_authenticated:  #if current user is logged in redirect them to the home page
        return redirect(url_for('main1.home'))
    form = RegistrationForm()
    #Check if the data entered is validate for the form
    if form.validate_on_submit():  #CHECKING IF FORM IS VALIDATE ON SUBMIT
        #Hash Password
        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)  #creates a new user
        db.session.add(user)  #add this user to the changes in our db
        db.session.commit(
        )  #commit these changes this will add the user to the database
        flash(
            'Your account has now been created! You are now able to log in',
            'success'
        )  #flash one time alert message, f string is used as we are passing in a variable
        #redirect to the home page after a successful creation
        return redirect(
            url_for('users.login')
        )  #login is the name of the function of the route, user is returned to login page
    return render_template('register.html', title='Register', form=form)
예제 #7
0
파일: routes.py 프로젝트: IlnurAgl/WebSite
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')
        if form.picture.data:
            picture_file = save_picture(form.picture.data)
            user = User(username=form.username.data,
                        email=form.email.data,
                        image_file=picture_file,
                        password=hashed_password)
        else:
            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', title='Регистрация', form=form)