Y
Y
Yura Yurievich2016-12-24 18:38:29
JavaScript
Yura Yurievich, 2016-12-24 18:38:29

How to save password for multiple forms in Chrome on ajax requests?

Good evening! you need to save the password in a pop-up form (from one) on the site.
But, if I go to the admin panel, and then on the site I enter the password to download the file from the site, then it offers to save the password for admin, the login under which I go to the admin panel.

My solution:
Create a js form that will have login:PassForDownload pass:password_for_download .
Send it to the server and, in theory, should save it not for admin , and then start downloading the file.

But, it still saves for admin.

Here is the code:

function alerttifyAcess(e)
{
    alertify
        .defaultValue(/*ls.getEmpOrVal("infDwldPass")*/)    //    concrete method
        .prompt("Введите пароль для скачивания",
            function (val, ev) {
                  saveAuthInfo(function() {
                    $.post($(e).attr('href') + ( $(e).attr("external") !== undefined ? "&check=true" : "" )).always(
                        function (data) {

                            if (data === 'KEY_NOT_VALID') {
                                alertify.error("Доступ ограничен");
                            }
                            else if (data === 'FILE_NOT_FOUND') {
                                alertify.error("Файл не найден.");
                            }
                            else {
                                location.href = $(e).attr('href');
                                alertify.success("Доступ разрешен.");
                            }
                        })
                }, 'Password for download content', val);
            },
            function(ev) {

            }
        );
}

function fakeSubmit(e) {
    e.preventDefault();

    return true;
}
function saveAuthInfo(afterSave, user, password) {
    $('body').append(
        '<form id="tmp-fakeform" action="/worker/fake-form" onsubmit="fakeSubmit(event)" hidden>' +
            '<input type="text" name="login" value="'+user+'">' +
            '<input type="password" name="password" value="'+password+'">' +
            '<input type="submit" name="sbtn">' +
        '</form>'
    );

    $('#tmp-fakeform').submit();


    afterSave();
}


PS
Links to remote resources and files on the server are protected by a password on the site. When clicked, alerttifyAcess fires , which protects)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question