Example #1
0
def new_pass_post():
    v = Validator(request.form)
    v.field('password_1').required()
    v.field('password_2').required()
    v.field('password_2').equal(v.field('password_1'), message="Повторый пароль неверный")
    if v.is_valid():
        restore_pass = PasswordRestore.is_valid_token(request.form.get("token"))
        if not restore_pass:
            abort(404)
        new_password = request.form.get("password_1")
        restore_password(restore_pass.author.login, new_password)
        PasswordRestore.deactivation_token(restore_pass)
        return jsonify({"status": "ok"})
    return jsonify({"status": "fail",
                    "errors": v.errors})
Example #2
0
def restore_post():
    v = Validator(request.form)
    v.field('email').required().email()
    if v.is_valid():
        email = request.form.get("email")
        user = User.get_by_email(email)
        if user:
            token = PasswordRestore.add_token(user)
            print(token)
            send_password_restore_ref.delay(user.email, user.full_name, token)
        return jsonify({"status": "ok"})
    return jsonify({"status": "fail",
                    "errors": v.errors})
Example #3
0
def restore_pass(token):
    pass_restore = PasswordRestore.is_valid_token(token)
    if not pass_restore:
        abort(404)
    return render_template('password/new_pass.html', token=pass_restore.token)