Пример #1
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        flash(f'Account created for {form.username.data}!', 'success')
        return redirect(url_for('home'))

    return render_template('register.html.jinja', title='Register', form=form)
Пример #2
0
def register():
    # If Current user is authenticated, redirect to homepage
    if current_user.is_authenticated:
        return redirect(url_for("home"))

    form = RegistrationForm()
    # To check Validation
    if form.validate_on_submit():
        # Hash user password
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode("utf-8")

        # Collect data form the Form Fields and instantiate to the "User" Model
        user = User(username=form.username.data,
                    email=form.email.data,
                    password=hashed_password)

        # Add User
        db.session.add(user)
        # Create user Account
        db.session.commit()
        flash("Your account has been created you're now able to login!",
              "success")
        return redirect(url_for("login"))
    return render_template("register.html", title="Register", form=form)
Пример #3
0
def register():
    form = RegistrationForm()
    #hidden_tag(): Adds Cross Site Request Forgery Token
    if form.validate_on_submit():
        flash(f'Account Created for {form.username.data}.', 'success')
        return redirect(
            url_for('home')
        )  #url_for takes the name of method like home, register, login not html page
    return render_template('register.html', title='Signup', form=form)
Пример #4
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = RegistrationForm(request.form)
    if request.method == "POST" and 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 for {0}!".format(form.username.data))
        return redirect(url_for('login'))
    return render_template("register.html", title="Register", form=form)
Пример #5
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('hello'))
    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 are now able to log in','success')
        return redirect(url_for('login'))
    return render_template('register.html',title='Register',form=form)
Пример #6
0
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(f'Account created for {form.username.data},You can login now.')
        return redirect(url_for("login"))
    return render_template('register.html', title="register", form=form)
Пример #7
0
def register():
    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'{form.username.data} account has been created', 'success')
        return redirect(url_for('home'))
    return render_template('register.html', title='Register', form=form)
Пример #8
0
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 = User(username=form.username.data,
                    email=form.email.data,
                    password=hashed_pw)
        db.session.add(user)
        db.session.commit()
        flash("Your account has been created!", "success")
        return redirect(url_for("login"))
    return render_template("register.html", title='register', form=form)
Пример #9
0
def register():
    if current_user.is_authenticated:  # this will check current user authenticated and re direct to home page if user logged in and click on register button
        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(f'Account created for {form.username.data} !!!', 'success')
        return redirect(url_for('login'))
    return render_template('register.html', title="Register", form=form)
Пример #10
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = RegistrationForm()
    if form.validate_on_submit():
        # Hash the password from form
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        # Create user variable with form data and hashed pass AND add into db
        user = User(username=form.username.data,
                    email=form.email.data, password=hashed_password)
        db.session.add(user)
        db.session.commit()
        flash(f"You account has been created! You are now able to log in!", 'success')
        return redirect(url_for('login'))
    return render_template('register.html', title='Register', form=form)
Пример #11
0
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(f'Account {form.username.data} registered successfully.',
              category='success')
        return redirect(url_for('login'))
    return render_template('register.html', title='Register', form=form)
Пример #12
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('homepage'))
    form = RegistrationForm()
    if form.validate_on_submit():
        h_pass = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = User(username=form.username.data,
                    email=form.email.data,
                    password=h_pass)
        db.session.add(user)
        db.session.commit()
        flash('Account created for {}'.format(form.username.data),
              'success')  ### changed lates
        return redirect(url_for('login'))
    return render_template('register.html', title="Register", form=form)
Пример #13
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = RegistrationForm()
    if form.validate_on_submit():
        hash_pwd = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user_1 = User(username=form.username.data,
                      email=form.email.data,
                      password=hash_pwd)
        db.session.add(user_1)
        db.session.commit()

        flash(f'Your Account created for {form.username.data}!', 'success')
        # 'success' message here is falls in type category
        return redirect(url_for('login'))
    return render_template('register.html', title='Register', form=form)
Пример #14
0
def register():
    if current_user.is_authenticated:
        return redirect("home")

    form = RegistrationForm()

    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode("utf-8")

        newUser = User(username=form.username.data,
                       email=form.email.data,
                       password=hashed_password)

        db.session.add(newUser)
        db.session.commit()

        flash("Account Created Successfully", "success")
        return redirect('login')

    return render_template("register.html", form=form)
Пример #15
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = RegistrationForm()
    if form.validate_on_submit():
        # check if user already have account
        user = User.query.filter_by(email=form.email.data).first()
        if user:
            #print(user)
            flash(f'Seems this email is already registered try to log in',
                  'danger')
            return redirect(url_for('login'))
        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(f'Your Account has been created! now you can log in ',
                  'success')
            return redirect(url_for('login'))
    return render_template('register.html', title='Register', form=form)
Пример #16
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        flash('Account created', category='success')
        return redirect(url_for('home'))
    return render_template('register.html', title='Registration', form=form)