Пример #1
0
 def __init__(self, email, password, first_name, last_name, mobile_no,
              gender, dob, profile_pic):
     self.username = str(email).split('@')[0]
     self.email = email
     self.password = bcrypt.generate_password_hash(password).decode('utf-8')
     self.first_name = first_name
     self.last_name = last_name
     self.mobile_no = mobile_no
     self.gender = gender
     self.dob = dob
     self.profile_pic = profile_pic
Пример #2
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(f'Your Account has been Created! You can able to Log in now','success')
        return redirect(url_for('users.login'))
    return render_template('register.html', title='Resgister', form=form)
Пример #3
0
def reset_token(token):
    if current_user.is_authenticated:
        return redirect(url_for('main.home'))
    user = User.verify_reset_token(token)
    if user is None:
        flash('That is an invalid or expird token','warning')
        return redirect(url_for('users.reset_request'))
    form = ResetPasswordForm()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8')
        user.password = hashed_password
        db.session.commit()
        flash(f'Your Password t has been Updated! You can able to Log in now','success')
        return redirect(url_for('users.login'))
    return render_template('reset_token.html', title='Reset Password', form=form)
Пример #4
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('Twoje konto zostało utworzone! Możesz się zalogować', 'success')
        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('home'))
    form = RegistrationForm()
    if form.validate_on_submit():
        hased_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = User(username=form.username.data,
                    email=form.email.data,
                    password=hased_password)
        db.session.add(user)
        db.session.commit()
        flash(f'Account Created for {form.username.data}!', 'green')
        return redirect(url_for('login'))
    return render_template('auth/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_pw = bcrypt.generate_password_hash(form.password.data).decode('utf-8')
        user_collection.insert_one({
            'username': form.username.data,
            'password': hashed_pw,
            'email': form.email.data,
            'image': 'default.jpeg',
            'posts': []
        })
        flash(f'Your Account Has Been Createad! You Can Login Now', 'success')
        return redirect(url_for('login'))
    return render_template('register.html', title = 'Register', form = form)
Пример #7
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = RegForm()
    if form.validate_on_submit():
        userm = User.query.filter_by(email=form.email.data).first()
        usern = User.query.filter_by(username=form.username.data).first()
        if userm is None and usern is None:
            hashedPassword = bcrypt.generate_password_hash(form.password.data).decode('utf-8')
            newUser = User(username=form.username.data, email=form.email.data, password=hashedPassword)
            db.session.add(newUser)
            db.session.commit()
            flash('Account created successfully', 'success')
            return redirect(url_for('login'))
        else:
            flash('Account with that name or email already exists', 'danger')
    return render_template('register.html', title='Register', form=form)
Пример #8
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('main.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()

        # Bootstrap categozization of flash includes success
        flash('Your account has been created.', 'success')
        return redirect(url_for('users.login'))
    return render_template('register.html', title='Register', form=form)