Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
Updated javascript example
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGhostHunter committed Aug 4, 2020
1 parent fcb0991 commit 9e4bcf2
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,15 @@ You will receive the `vendor/larapass/js/larapass.js` file which you can include
```html
<script src="{{ asset('vendor/larapass/js/larapass.js') }}"></script>

<!-- Registering users -->
<!-- Registering credentials -->
<script>
const register = () => {
const register = (event) => {
event.preventDefault()
new Larapass({
register: 'webauthn/register',
registerOptions: 'webauthn/register/options'
}).register()
.then(response => window.location.href = 'https://myapp.com/devices')
.then(response => alert('Registration successful!'))
.catch(response => alert('Something went wrong, try again!'))
}
Expand All @@ -169,21 +170,22 @@ You will receive the `vendor/larapass/js/larapass.js` file which you can include

<!-- Login users -->
<script>
const login = () => {
const login = (event) => {
event.preventDefault()
new Larapass({
login: 'webauthn/register',
loginOptions: 'webauthn/register/options'
}).login({
email: document.getElementById('email').value,
}).then(response => window.location.href = 'https://myapp.com/account')
email: document.getElementById('email').value
}).then(response => alert('Authentication successful!'))
.catch(error => alert('Something went wrong, try again!'))
}
document.getElementById('login-form').addEventListener('submit', login)
</script>
```

You can bypass the route list declaration if you're using the defaults. The example above includes them just for show.
> You can bypass the route list declaration if you're using the defaults. The example above includes them just for show. Be sure to create modify this script for your needs.
Also, the helper allows headers on the action request, on both registration and login.

Expand All @@ -194,7 +196,7 @@ new Larapass({
}).login({
email: document.getElementById('email').value,
}, {
myHeader: 'This is sent with the signed challenge',
'My-Custom-Header': 'This is sent with the signed challenge',
})
```

Expand Down

0 comments on commit 9e4bcf2

Please sign in to comment.