Validation with Phonegap and WebService

1

I am validating the login and password fields via Web Services, it returns me if the login is valid and generates a cookie number (made via sql), so far so good, I can perform normal validation but the following doubt came to me (I took a good look at the internet on cookie validation using jquery), how do I validate this value for the system via WEBSERVICE and if the user has already logged in once and needs to close the application, he continues with his credentials valid.

So far my code is like this (I tried to use the $ cookie to write the value):

$.ajax({
                type: 'POST'
                //Caminho do WebService + / + nome do metodo
                , url: "http://localhost:11078/wsLogin.asmx/Login"
                , crossDomain: true
                , contentType: 'application/json; charset=utf-8'
                , dataType: 'json'
                //Abaixo adicione as variáveis caso haja alguma.
                , data: "{chave:'" + email + "', senha:'" + senha + "'}"
                , success: function (data, status) {
                    var txtHValue = $("#email");
                    var valoresID;
                    var arrCookie = [];
                    var arrLoginStatus = [];
                    var arrUsuarioID = [];

                    for (var i = 0; i < data.d.length; i++) {

                        var item = JSON.stringify(data.d[i]["ID"]);

                        arrCookie.push(data.d[i]["Cookie"]);
                        arrLoginStatus.push(data.d[i]["LoginStatus"]);
                        arrUsuarioID.push(data.d[i]["UsuarioID"]);
                    }


                    switch (parseInt(arrLoginStatus)) {
                        case 0:
                            alert("Usuario Não Encontrado");
                            break;
                        case 1:
                            alert("UsuarioAtivo");
                            break;
                        case 2:
                            txtHValue.focus();
                            $("#msgErro").text("Necessario preencher os campos corretamentes");
                            break;
                        case 5:
                            alert("SenhaValida");
                            break;
                        case 4:
                            alert("UsuarioEncontrado");
                            break;
                        case 7:
                            var list = $.cookie("example", "" + arrCookie);
                            alert(list);

                            break;
                        case 8:
                            alert("UsuarioDuplicado");
                            break;
                        case 9:
                            alert("ChaveLicencaNaoLocalizada");
                            break;
                        case 10:
                            alert("LicencaExpirada");
                            break;
                        case 11:
                            alert("ExcessaoGenerica");
                            break;
                        case 16:
                            alert("LogonExpirado");
                            break;

                    }

                }
                , error: function (xmlHttpRequest, status, err) {
                    //Caso ocorra algum erro:
                    $('.alert').html('Ocorreu um erro');
                }
            });

        });
    });
    
asked by anonymous 27.04.2018 / 18:58

0 answers