Beispiel #1
0
def resend():
    form = UsernameForm()
    if form.validate_on_submit():
        user = User.query.filter_by(
            username=form.username.data.lower()).first_or_404()
        if user.email_confirmed == True:
            flash("Your email is already confirmed!", "error")
        elif send_confirm_link(user.id, user.email):
            flash("New confirmation link sent, check your email!", "success")
            return redirect(url_for("index"))
    return render_template("resend.html", form=form)
Beispiel #2
0
def input():
    form = UsernameForm()
    if form.validate_on_submit():
        return redirect(
            url_for('results',
                    white_username=form.white.data,
                    black_username=form.black.data,
                    evaluation=form.evaluation.data,
                    white_clock=form.white_clock.data,
                    black_clock=form.black_clock.data,
                    perf=form.perf.data))
    return render_template('home.html', post='Be', form=form)
Beispiel #3
0
def reset():
    if current_user.is_authenticated:
        return redirect(url_for("index"))

    form = UsernameForm()
    if form.validate_on_submit():
        user = User.query.filter_by(
            username=form.username.data.lower()).first_or_404()
        subject = "Password reset requested"
        token = ts.dumps(user.username, salt="recover-key")
        recover_url = url_for("reset_with_token", token=token, _external=True)
        html = render_template("email/recover.html", recover_url=recover_url)
        if send_email(user.email, subject, html):
            flash("A password reset link has sent to your email address", "success")
            return redirect(url_for("index"))
    return render_template("reset.html", form=form)
Beispiel #4
0
def inputusername():
    """Check user's answer for reseting password."""

    form = UsernameForm()

    if form.validate_on_submit():
        user = Users.query.filter(Users.username == form.username.data)
        if (user.count() > 0):
            question_id = user[0].question_id
            question = Questions.query.get_or_404(question_id).question

            session['question'] = question
            session['username'] = form.username.data
            return redirect('/checkanswer')

        flash("Wrong username, please try again.")

    return render_template('users/inputusername.html', form=form)