Skip to content

Conversation

@Engerrs
Copy link
Member

@Engerrs Engerrs commented Oct 27, 2025

No description provided.

if not ah.is_2fa_dev_mode_enabled():
tk.abort(404, tk._("Not found"))

user_name: str = tk.get_or_bust(dict(tk.request.form), "login")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leads to 500 error without login. Should check for it and return 400 bad request if not here.

@auth.route("/get-user-code", methods=["POST"])
def get_2fa_user_code() -> Response:
    if not ah.is_2fa_dev_mode_enabled():
        return tk.abort(404, tk._("Not found"))

    user_name = tk.request.form.get("login")

    if not user_name:
        return tk.abort(400, tk._("Missing 'login' parameter"))

    user = model.User.get(user_name)

    if not user or not user.email:
        return tk.abort(404, tk._("User not found or has no email set"))

    code = utils.get_email_verification_code(user)

    log.info("Providing 2FA code %s for user %s in dev mode", code, user.name)

    return jsonify({"success": True, "result": {"code": code}})

},

_show_user_code: function () {
const is_dev_mode = $('.dev-mode-user-code');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to initialize, as other containers.

this.devModeCodeBlock = $("#dev-mode-user-code");

Then

_showUserCode: function () {
    if (this.devModeCodeBlock.length !== 1) {
        return;
    }

    $.ajax({
        url: "/mfa/get-user-code",
        method: "POST",
        data: this.form.serialize(),
        success: (response) => {
            if (!response?.success) return;

            this.devModeCodeBlock.find('.code-wrapper').text(response.result.code);
            this.devModeCodeBlock.show();
        },
        error: (resp) => {
            console.error(resp);
        }
    });
},

if (this.isEmailMfa) {
this._setResendCountdown();
this._sendVerificationCode();
this._show_user_code();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not going to work like that. Should be moved to _sendVerificationCode -> complete.

complete: () => {
    this.submitBtn.prop("disabled", false);
    this._showUserCode();
}

@mutantsan mutantsan merged commit de5b0a5 into DataShades:master Oct 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants