Skip to content

Instantly share code, notes, and snippets.

@mford22392
Created November 21, 2019 15:43
Show Gist options
  • Save mford22392/3ecf8430115e51f994fb4c6a69b17702 to your computer and use it in GitHub Desktop.
Save mford22392/3ecf8430115e51f994fb4c6a69b17702 to your computer and use it in GitHub Desktop.
import * as React from 'react';
import auth0 from 'auth0-js';
const webAuth = new auth0.WebAuth({
clientID: process.env.AUTH0_CLIENT_ID || '',
domain: 'auth.guildacceptance.com',
responseType: 'token id_token',
redirectUri: window.location.href.replace('input', 'success'),
});
const handleSendCode = () => {
const emailInput = (document.getElementById('email') as HTMLInputElement);
const value = emailInput.value;
webAuth.passwordlessStart(
{
connection: 'email',
send: 'code',
email: value,
},
function(err, res) {
console.log(err);
console.log(res);
}
);
}
const handleSubmit = () => {
const codeInput = (document.getElementById('code') as HTMLInputElement).value;
const emailInput = (document.getElementById('email') as HTMLInputElement).value;
webAuth.passwordlessLogin(
{
connection: 'email',
email: emailInput,
verificationCode: codeInput
},
function(err, res) {
console.log(err);
console.log(res);
}
);
}
export const VerificationInput = () => {
return (
<div>
<h1>Verification Input</h1>
<input type='text' name='email' id='email' placeholder="email" />
<button onClick={() => handleSendCode()}>Send Code</button>
<br />
<input type='text' name='code' id='code' placeholder="code" />
<button onClick={() => handleSubmit()}>Click</button>
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment