Last active
June 3, 2021 17:11
-
-
Save brissmyr/24b5f1b52c16f88d5dc053cbba7d814f to your computer and use it in GitHub Desktop.
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
<script> | |
var form = document.getElementById('new_user') | |
form.onsubmit = function(e) { | |
e.preventDefault(); | |
_castle('createRequestToken').then(function(requestToken) { | |
// Populate a hidden field called `castle_request_token` with the | |
// request token | |
var hiddenInput = document.createElement('input'); | |
hiddenInput.setAttribute('type', 'hidden'); | |
hiddenInput.setAttribute('name', 'castle_request_token'); | |
hiddenInput.setAttribute('value', requestToken); | |
// Add the hidden field to the form so it gets sent to the server | |
// before submitting the form | |
form.appendChild(hiddenInput); | |
form.submit(); | |
}); | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment