Skip to content

Commit

Permalink
chore: add a page for testing login CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
tkurki committed Oct 9, 2022
1 parent 9969ed6 commit dab8150
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions public/examples/loginform.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<title>Login form</title>
</head>

<body>
<form id="loginForm">
<input type="text" id="username" /><br />
<input type="password" id="password" /><br />
<button type="submit">Submit</button>
<p id="result"></p>
</form>
</body>
<script>
window.onload = function () {
document.getElementById('loginForm').onsubmit = function () {
document.getElementById('result').innerHTML = ''
const username = document.getElementById('username').value
const password = document.getElementById('password').value
const body = JSON.stringify({ username, password })
fetch('http://localhost:3000/signalk/v1/auth/login', {
method: 'POST',
withCredentials: true,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body
})
.then(r => r.json())
.then(r => {
document.getElementById('result').innerHTML = JSON.stringify(r)
})
return false;
}
}
</script>

</html>

0 comments on commit dab8150

Please sign in to comment.