Пример #1
0
    def generate_fake(count=100):
        from sqlalchemy.exc import IntegrityError
        from random import seed
        import forgery_py

        seed()
        for i in range(count):
            user = User(email=forgery_py.internet.email_address(),
                        username=forgery_py.internet.user_name(),
                        password=forgery_py.lorem_ipsum.word())

            db_session.add(user)

        try:
            db_session.commit()
        except IntegrityError:
            db_session.rollback()
Пример #2
0
def active_account():
    key = request.args.get('key')
    email = request.args.get('email')

    if not key or not email:
        abort(404)

    email = email.strip().lower()

    user_id = redis_cli.get(key)
    user = User.query.get(user_id)

    if user.email == email:
        user.active = True
        db_session.commit()
        login_user(user)

    return redirect(url_for('index.index'))
Пример #3
0
def active_account():
    key = request.args.get('key')
    email = request.args.get('email')

    if not key or not email:
        abort(404)

    email = email.strip().lower()

    user_id = redis_cli.get(key)
    user = User.query.get(user_id)

    if user.email == email:
        user.active = True
        db_session.commit()
        login_user(user)

    return redirect(url_for('index.index'))
Пример #4
0
def register():
    form = RegisterForm()

    context = {'form': form}

    if request.method == 'POST' and form.validate_on_submit():
        user = User()
        user.email = form.email.data.strip().lower()
        user.password = form.password.data.strip()
        user.username = user.email

        db_session.add(user)
        db_session.commit()

        login_user(user)

        user.send_register_mail(request.host_url)

        return redirect(url_for("index.index"))

    return render_template("auth/register.html", **context)
Пример #5
0
def register():
    form = RegisterForm()

    context = {
        'form': form
    }

    if request.method == 'POST' and form.validate_on_submit():
        user = User()
        user.email = form.email.data.strip().lower()
        user.password = form.password.data.strip()
        user.username = user.email

        db_session.add(user)
        db_session.commit()

        login_user(user)

        user.send_register_mail(request.host_url)

        return redirect(url_for("index.index"))

    return render_template("auth/register.html", **context)