Created
January 29, 2017 05:56
-
-
Save thangman22/8c5342c883afe022f9f03b160847c707 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
navigator.credentials.get({ | |
password: true | |
}).then(function(cred) { | |
console.log(cred) | |
if(cred){ | |
$("#status").append("<li>Login Credential Found</li>") | |
fetch('login.php', { | |
method: 'POST', | |
credentials: cred | |
}).then(function(res) { | |
return res.text(); | |
}).then((text) => { | |
$("#status").append("<li>Auto Login [" + cred.id + "] Complete</li>") | |
}) | |
} | |
}) | |
document.querySelector('#loginForm').addEventListener("submit", e => { | |
e.preventDefault(); | |
if (navigator.credentials) { | |
console.log(e.target) | |
let form = document.querySelector('#loginForm') | |
let c = new PasswordCredential(e.target) | |
navigator.credentials.store(c) | |
fetch('login.php', { | |
method: 'POST', | |
credentials: c | |
}).then(function(res) { | |
return res.text(); | |
}).then((text) => { | |
$("#status").append("<li>Login Complete</li>") | |
}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment