Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CHECK IF USER HAS AUTHENTICATED
- var username = document.cookie.replace(/(?:(?:^|.*;\s*)username\s*\=\s*([^;]*).*$)|^.*$/, "$1");
- var password = document.cookie.replace(/(?:(?:^|.*;\s*)password\s*\=\s*([^;]*).*$)|^.*$/, "$1");
- if (username == "" || password == ""){
- window.location.replace("http://www.returnit.com:8080/returnitRest/login.html")
- }else{
- $.ajax( {
- method: "POST",
- url: "http://www.returnit.com:8080/returnitRest/rest/user/authentication",
- beforeSend: function (xhr) {
- xhr.setRequestHeader ("Authorization", "Basic " + window.btoa(username + ":" + password));
- },
- // data: $.param(userFilter, true),
- contentType: "application/json",
- async: false
- } )
- .done( function(response){
- alert("authentication successful")
- })
- .fail( function(jqXHR){
- alert(jqXHR.statusText);
- window.location.replace("http://www.returnit.com:8080/returnitRest/login.html")
- });
- }
- // END OF AUTHENTICATION
- var clients;
- var oldProduct;
- var curProductList = {};
- var curProductIndex;
- var userFilter = {
- "inputEmail" : "",
- "inputFirstName" : "",
- "inputLastName" : "",
- "inputType" : "client"
- };
- $.ajax( {
- // method: "POST",
- url: "http://www.returnit.com:8080/returnitRest/rest/user",
- data: $.param(userFilter, true),
- contentType: "application/json"
- } )
- .done( function(response){
- clients = response;
- var options = $("#inputClient");
- options.append($("<option />").val("").text("All clients"));
- $.each(clients, function() {
- options.append($("<option />").val(this.id).text(this.firstName + " " + this.lastName)); // TODO using email as key atm, should we use ID instead?
- });
- })
- .fail( function(jqXHR){
- alert(jqXHR.statusText);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement