Beispiel #1
0
def signup():
    form = RegistrationForm()

    if form.validate_on_submit():
        proposed_username = name_generator_STRING()
        proposed_password = passcode_generator_INT()

        if proposed_username in fake_name_db_ARRAY:
            proposed_username = proposed_username + ("%d" % randbelow(999))

        fake_name_db_ARRAY.append(proposed_username)
        fake_logger_ARRAY.append({proposed_username, proposed_password})

        print(fake_logger_ARRAY)

        userToBeAdded = UserAccount(username=name_generator_STRING(),
                                    mobile=form.mobile.data,
                                    email=form.email.data,
                                    passcode="%d" % proposed_password,
                                    ip_address=request.environ['REMOTE_ADDR'])
        try:
            session.add(userToBeAdded)
            session.commit()
        except:
            session.rollback()
            flash('This account already exists, please login')

    return render_template('signup.html', form=form)
Beispiel #2
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, password=form.password.data)

        db.session.add(user)
        db.session.commit()
        flash("thank you for registering")
        return redirect(url_for('login'))
    return render_template('register.html', form=form)
Beispiel #3
0
def register():
    form = RegistrationForm()

    if form.validate_on_submit():
        user = User(True, form.username.data, form.email.data)
        user.set_password(form.password.data)
        user.add_user()
        return user.get_user(form.username.data)

    flash_errors(form.errors.items())

    return render_template('register.html', title='Register', form=form)
Beispiel #4
0
def registration():
    if request.method == 'GET':
        form = RegistrationForm()
        return render_template('registration.html',
                               form=form,
                               error=form.errors)
    else:
        form = RegistrationForm()
        if form.validate_on_submit():
            try:
                if User.query.filter_by(email=form.email.data).first():
                    message_body = 'User already exists'
                    message_title = 'Oops!'
                    return render_template('message.html',
                                           message_title=message_title,
                                           message_body=message_body)

                else:
                    new_user = User(email=form.email.data,
                                    first_name=form.first_name.data,
                                    surname=form.surname.data,
                                    password_hash=generate_password_hash(
                                        form.password.data))
                    send_confirmation_email(new_user.email)
                    db.session.add(new_user)
                    db.session.commit()
            except (ValueError, TypeError):
                message_body = 'Registration failed'
                message_title = 'Error!'
                return render_template('message.html',
                                       message_title=message_title,
                                       message_body=message_body)
        else:
            return render_template('registration.html',
                                   form=form,
                                   error=form.errors)
        message_body = 'The registration was successful.'
        message_title = 'Success!'
        return render_template('message.html',
                               message_title=message_title,
                               message_body=message_body)
Beispiel #5
0
def register():
    f = RegistrationForm(request.form)
    if request.method == "POST" and f.validate_on_submit():
        return register_user(f.username.data, f.password.data)
    else:
        return render_template('register.html', form=f)
Beispiel #6
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', title='Register', form=form)