Exemplo n.º 1
0
def register():
    if request.method == 'POST':
        name = request.form['name']
        lastname = request.form['lastname']
        email = request.form['email']
        password = request.form['password']
        confirm_password = request.form['confirm_password']
        if password != confirm_password:
            return render_template('register.html')
        pw_hash = bcrypt.generate_password_hash(password)
        user = \
            User(name=name, lastname=lastname, email=email, password=pw_hash)
        db.session.add(user)
        db.session.commit()
        return redirect(url_for('login'))
    return render_template('register.html')
Exemplo n.º 2
0
def registration():
    if request.method == 'POST':
        name = request.form['name']
        last_name = request.form['last_name']
        phone_numbe = request.form['phone_numbe']
        email = request.form['email']
        password = request.form['password']
        pw_hash = bcrypt.generate_password_hash(password)
        user = User(name=name,
                    last_name=last_name,
                    phone_numbe=phone_numbe,
                    email=email,
                    password=pw_hash)
        db.session.add(user)
        db.session.commit()
        return redirect("users")
    return render_template("registration.html")
Exemplo n.º 3
0
    def signup(cls, username, password, email, image_url):
        """Sign up user.
        Hashes password and adds user to system.
        """

        hashed_pwd = bcrypt.generate_password_hash(password).decode('UTF-8')

        # import pdb
        # pdb.set_trace()

        user = User(username=username,
                    password=hashed_pwd,
                    email=email,
                    image_url=image_url)

        db.session.add(user)
        db.session.commit()
        return user
Exemplo n.º 4
0
def register():
    error = None
    status_code = 200
    form = RegisterForm(request.form)
    if request.method == 'POST':
        if form.validate():
            new_user = User(form.name.data, form.email.data,
                            bcrypt.generate_password_hash(form.password.data))
            try:
                db.session.add(new_user)
                db.session.commit()
                flash('Thanks for registering.')
                return redirect(url_for('login'))
            except IntegrityError:
                error = 'That username and/or email already exists'
                return render_template('forms/register.html',
                                       error=error,
                                       form=form)
    return render_template('forms/register.html', form=form,
                           error=error), status_code
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)
        #user = Users(firstName, lastName, email, username, password)
        user = Users(firstname=form.firstname.data,
                     lastname=form.lastname.data,
                     email=form.email.data,
                     username=form.username.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')
        #session['logged_in'] = True

        return redirect(url_for('auth.login'))
    return render_template('registration.html', title='Register', form=form)
Exemplo n.º 6
0
 def __generate_hash(password):
     return bcrypt.generate_password_hash(password,
                                          rounds=10).decode("utf-8")
Exemplo n.º 7
0
def set_pass(user, new_pass):
    user = User.query.filter_by(nickname = user.nickname).first()
    user.password = bcrypt.generate_password_hash(new_pass)
    db.session.commit()
    return flash('Password changed!')
Exemplo n.º 8
0
def make_password(password):
    hashed = bcrypt.generate_password_hash(password)
    hashed_utf8 = hashed.decode("utf8")
    return hashed_utf8