Example #1
0
def create_user():

    if current_user.is_anonymous():
        return redirect(url_for('auth.login'))

    form = RegistrationForm()

    if request.method == "POST":

        if not form.validate():
            flash('Form invalid', 'warning')
            return redirect(url_for('auth.create_user'))

        if User.get_by_username(request.form['username']):
            flash('Username is taken', 'warning')
            return redirect(url_for('auth.create_user'))

        if User.get_by_email(request.form['email']):
            flash('Email is taken', 'warning')
            return redirect(url_for('auth.create_user'))

        User.create(request.form['username'], request.form['email'], request.form['password'])

        flash("User %s created" % request.form['username'])

    return render_template("auth/create_user.html", form=form)
Example #2
0
def change_password():
    if current_user.is_anonymous():
        return redirect(url_for('auth.login'))

    form = PasswordChangeForm()

    if request.method == "POST":
        User.change_password(current_user, request.form['old_password'], request.form['new_password'])
        flash("Password changed")

    return render_template("auth/change_password.html", form=form)
Example #3
0
def create_user(username, email, password):
    """ Create a new user
    """
    show_pass = not password

    if not password:
        password = random_string(12)

    if User.get_by_username(username):
        red("Username %s already exists" % username)
        return

    if User.get_by_email(email):
        red("Email %s already exists" % email)
        return

    User.create(username, email, password)
    green("User %s created" % username)

    if show_pass:
        yellow("Password: %s" % password)
Example #4
0
def create_user(username, email, password):
    """ Create a new user
    """
    show_pass = not password

    if not password:
        password = random_string(12)

    if User.get_by_username(username):
        click.secho("Username %s already exists" % username, fg='red')
        return

    if User.get_by_email(email):
        click.secho("Email %s already exists" % email, fg='red')
        return

    User.create(username, email, password)
    click.secho("User %s created" % username, fg='green')

    if show_pass:
        click.secho("Password: %s" % password, fg='yellow')
Example #5
0
def create_user(username, email, password):
    """ Create a new user
    """
    show_pass = not password

    if not password:
        password = random_string(12)

    if User.get_by_username(username):
        red("Username %s already exists" % username)
        return

    if User.get_by_email(email):
        red("Email %s already exists" % email)
        return

    User.create(username, email, password)
    green("User %s created" % username)

    if show_pass:
        yellow("Password: %s" % password)
Example #6
0
def register():

    if not current_app.config['REGISTRATION_ENABLED']:
        flash("Registration is disabled")
        return redirect(url_for(current_app.config['ROOT_ENDPOINT']))

    form = RegistrationForm()

    if request.method == "POST":

        if not form.validate():
            flash('Form invalid', 'warning')
            return redirect(url_for('auth.register'))

        if User.get_by_username(request.form['username']):
            flash('Username is taken', 'warning')
            return redirect(url_for('auth.register'))

        if User.get_by_email(request.form['email']):
            flash('Email is taken', 'warning')
            return redirect(url_for('auth.register'))

        User.create(request.form['username'], request.form['email'],
                    request.form['password'])
        User.auth(request.form['email'], request.form['password'])

        return redirect(
            request.args.get("next")
            or url_for(current_app.config['ROOT_ENDPOINT']))

    return render_template("auth/register.html", form=form)
Example #7
0
def register():

    if not current_app.config['REGISTRATION_ENABLED']:
        flash("Registration is disabled")
        return redirect(url_for(current_app.config['ROOT_ENDPOINT']))

    form = RegistrationForm()

    if request.method == "POST":

        if not form.validate():
            flash('Form invalid', 'warning')
            return redirect(url_for('auth.register'))

        if User.get_by_username(request.form['username']):
            flash('Username is taken', 'warning')
            return redirect(url_for('auth.register'))

        if User.get_by_email(request.form['email']):
            flash('Email is taken', 'warning')
            return redirect(url_for('auth.register'))

        User.create(request.form['username'], request.form['email'], request.form['password'])
        User.auth(request.form['email'], request.form['password'])

        return redirect(request.args.get("next") or url_for(current_app.config['ROOT_ENDPOINT']))

    return render_template("auth/register.html", form=form)
Example #8
0
def login():
    form = LoginForm()

    if request.method == "POST":
        if not form.validate():
            flash('Form invalid', 'warning')
            return redirect(url_for('auth.login'))

        if User.auth(request.form['email'], request.form['password']):
            return redirect(request.args.get("next") or url_for(config.ROOT_ENDPOINT))
        else:
            flash('Email or Password Incorrect', 'warning')
            return redirect(url_for('auth.login'))

    return render_template("auth/login.html", form=form)
Example #9
0
def login():
    form = LoginForm()

    if request.method == "POST":
        if not form.validate():
            flash('Form invalid', 'warning')
            return redirect(url_for('auth.login'))

        if User.auth(request.form['email'], request.form['password']):
            return redirect(
                request.args.get("next") or url_for(config.ROOT_ENDPOINT))
        else:
            flash('Email or Password Incorrect', 'warning')
            return redirect(url_for('auth.login'))

    return render_template("auth/login.html", form=form)
Example #10
0
def logout_page():
    User.logout()
    flash("You are now logged out")
    return redirect(url_for(current_app.config['ROOT_ENDPOINT']))
Example #11
0
def logout():
    User.logout()
    return redirect(url_for(current_app.config['ROOT_ENDPOINT']))
Example #12
0
def logout():
    User.logout()
    return redirect("/")
Example #13
0
def logout():
    User.logout()
    return redirect(url_for(current_app.config['ROOT_ENDPOINT']))
Example #14
0
def logout_page():
    User.logout()
    flash("You are now logged out")
    return redirect(url_for(config.ROOT_ENDPOINT))
Example #15
0
def logout():
    User.logout()
    return redirect("/")
Example #16
0
def logout_page():
    User.logout()
    flash("You are now logged out")
    return redirect(url_for(config.ROOT_ENDPOINT))
Example #17
0
def logout_page():
    User.logout()
    flash("You are now logged out")
    return redirect(url_for(current_app.config['ROOT_ENDPOINT']))