-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improving preventDefault implementation
* Ensuring form submission is handled on non credentials enabled browsers.
- Loading branch information
1 parent
d2f0436
commit 6b14c4f
Showing
1 changed file
with
9 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,9 +81,12 @@ document.querySelector('#signout').addEventListener('click', function () { | |
*/ | ||
function handleFederation(e) { | ||
console.log("Signed in via a federation!"); | ||
e.preventDefault(); | ||
|
||
if (navigator.credentials) { | ||
// Stop the default form submission. | ||
e.preventDefault(); | ||
|
||
// In a real environment extract the credentials from the federated credential response. | ||
var c = new FederatedCredential({ | ||
id: '[email protected]', | ||
provider: 'https://accounts.federation.com/', | ||
|
@@ -107,9 +110,13 @@ function handleFederation(e) { | |
*/ | ||
document.querySelector('form').addEventListener('submit', function (e) { | ||
console.log("Submitted a sign-in form."); | ||
e.preventDefault(); | ||
|
||
if (navigator.credentials) { | ||
// Stop the default form submission. | ||
e.preventDefault(); | ||
|
||
// In a real site, we'd check the credentials are valid | ||
|
||
var c = new PasswordCredential({ | ||
id: document.querySelector('#username').value, | ||
password: document.querySelector('#password').value, | ||
|