Skip to content

Instantly share code, notes, and snippets.

@brissmyr
Last active June 3, 2021 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brissmyr/24b5f1b52c16f88d5dc053cbba7d814f to your computer and use it in GitHub Desktop.
Save brissmyr/24b5f1b52c16f88d5dc053cbba7d814f to your computer and use it in GitHub Desktop.
<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