Ejemplo n.º 1
0
def registration():
    if current_user.is_authenticated:
        return redirect(url_for('main.start'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(login=form.username.data)
        user.set_password(password=form.password.data)
        db.session.add(user)
        db.session.commit()
        return redirect(url_for('login.login'))
    return render_template('login/register.html', form=form)
Ejemplo n.º 2
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('main.index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        return redirect(url_for('auth.login'))
    return render_template('register.html', title=_('Register'), form=form)
Ejemplo n.º 3
0
def register_user():
    if current_user.is_authenticated:
        flash('You are already logged in')
        return redirect(url_for('main.display_books'))
    form = RegistrationForm()
    if form.validate_on_submit():
        User.create_user(user=form.name.data,
                         email=form.email.data,
                         password=form.password.data)
        flash('Registration Successful')
        return redirect(url_for('authentication.do_the_login'))

    return render_template('registration.html', form=form)
Ejemplo n.º 4
0
def register():
    if(current_user.is_authenticated):
        return redirect(url_for('home.index'))
    form = RegistrationForm()
    if(form.validate_on_submit()):
        print("Submission successful")
        customer = Customers(first_name=form.first_name.data, last_name=form.last_name.data, email=form.email.data)
        customer.set_password(form.password.data)
        db.session.add(customer)
        db.session.commit()
        flash('Congratulations, you have successfully registered!')
        return redirect(url_for('auth.login'))
    return render_template('auth/register.html', title='Register', form=form)
Ejemplo n.º 5
0
def signup():

    if current_user.is_authenticated:
        return redirect(url_for("main.home"))

    reg_form = RegistrationForm()

    if reg_form.validate_on_submit():
        username = reg_form.username.data
        password = reg_form.password.data
        email = reg_form.email.data
        optin_news = reg_form.optin_news.data

        # Add user to DB
        user = User(
            username=username,
            password=pbkdf2_sha512.hash(password),
            email=email,
            confirmed=False,
            created_on=datetime.datetime.utcnow(),
            optin_news=optin_news,
        )
        db.session.add(user)
        db.session.commit()

        # Add consent to DB (if given)
        if optin_news:
            consent = Consent(
                userID=user.userID,
                consent_type="news",
                consent_given_on=datetime.datetime.utcnow(),
                consent_given_via="signup_form",
            )
            db.session.add(consent)
            db.session.commit()

            # email verification needed for newsletter
            send_verification_email(user)
            flash("To receive newlsetter notifications you need to \
                   verify your email address. A verification email \
                   has been sent to your address.")

        # Log user in automatically
        login_user(user, remember=False)
        flash("Account registered successfully.", "success")
        return redirect(url_for("auth.signin"))

    return render_template("signup.html", reg_form=reg_form)
Ejemplo n.º 6
0
def register():
    # temporary removing registration
    flash('Registration is closed', 'danger')
    return redirect(url_for('auth.login'))
    if current_user.is_authenticated:
        return redirect(url_for('main.index'))

    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('Congratulations, you are now a registered user')
        return redirect(url_for('main.index'))
    return render_template('auth/register.html', title='Register', form=form)
Ejemplo n.º 7
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()
        token = user.generate_confirmation_token()
        send_email(user.email,
                   'Confirm Your Account',
                   'auth/email/confirm',
                   user=user,
                   token=token)
        flash('A confirmation email has been sent to you by email.')
        return redirect(url_for('main.index'))
    return render_template('auth/register.html', form=form)
Ejemplo n.º 8
0
def register():
    """
    Function to handle the rendering of the
    user registration page, as well as processing
    the submission of the registration form
    :return: rendered page
    """
    # Redirect request if user is already authenticated
    if current_user.is_authenticated:
        return redirect(url_for('main_app.index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        auth_tools.process_user_registration(form)
        return redirect(url_for('main_app.index'))
    return render_template(
        'register.html',
        title='Register',
        form=form
    )
Ejemplo n.º 9
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('main.index'))
    form = RegistrationForm()
    if form.validate_on_submit():

        user = None
        
        # If EMAIL_CONFIGURED environment variable is set
        # to false, all users are confirmed upon registration.
        # this is risky, because the only thing keeping someone
        # from highjacking the admin account is the registered
        # email addresses of users having to be confirmed.
        if os.getenv('EMAIL_CONFIGURED') != 0 and os.getenv('EMAIL_CONFIGURED') is not None:

            user = User(
                username=form.username.data,
                email=form.email.data.lower(), 
                confirmed=True
            )
            
        else:
            user = User(
                username=form.username.data,
                email=form.email.data.lower(),
                created = datetime.utcnow())
        
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()

        # Token for email confirmation email
        if os.getenv('EMAIL_CONFIGURED') != 0:
            send_confirmation_email(user)
            token = user.generate_confirmation_token()

        user_new = User.query.filter_by(username=user.username).first()
        flash("Congrats, you're now a user! We sent a confirmation link to your email.")
        return redirect(url_for("auth.login"))
    return render_template('auth/register.html', form=form)
Ejemplo n.º 10
0
def register():

    if current_user.is_authenticated:
        return redirect(url_for('main.index'))

    form = RegistrationForm()

    # check submitted form
    if form.validate_on_submit():

        user = User(username=form.username.data, email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()

        user.set_password(form.password.data)

        flash('Felicitaciones, usted se ha registrado exitosamente!')
        return redirect(url_for('auth.login'))

    return render_template('auth/register.html',
                           title='Registrarse',
                           form=form)
Ejemplo n.º 11
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('index'))

    form = RegistrationForm()

    if form.validate_on_submit():
        user = User(username=form.username.data, email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()

        user.set_password(form.password.data)

        login_user(user)

        next_page = request.args.get('next')

        if not next_page or url_parse(next_page).netloc != '':
            next_page = url_for('index')
        return redirect(next_page)

    return render_template('auth/register.html', title='Register', form=form)