-
-
Save architjn/3be15dca4be56ce7f980b3e93858bbe6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function make_base_auth(user, password) { | |
var tok = user + ':' + password; | |
var hash = btoa(tok); | |
return "Basic " + hash; | |
} | |
$.ajax({ | |
url: "https://haveibeenpwned.com/api/v2/breachedaccount/" + data.email, | |
method: "GET", | |
dataType: "json", | |
beforeSend: function (xhr){ | |
xhr.setRequestHeader('Authorization', make_base_auth(username, password)); | |
}, | |
success: function(msg){ | |
if(typeof mprogress != 'undefined'){ | |
mprogress.end(true); | |
} | |
clearRecords(); | |
msg.forEach(function(detail){ | |
addRecord(detail); | |
}); | |
showRecords(); | |
}, | |
error: function(jqXHR, textStatus, errorThrown){ | |
if(typeof mprogress != 'undefined'){ | |
mprogress.end(true); | |
} | |
if(jqXHR.status == 404){ | |
$('#records').html('No Records Found.'); | |
showRecords(); | |
} | |
// showAPIError(jqXHR.status, (jqXHR.responseJSON?jqXHR.responseJSON:(jqXHR.responseText === "Unauthorized"?{errors: ['Invalid Credentials']}:jqXHR.responseText))); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment