Last active
September 11, 2020 20:31
-
-
Save putrikarunia/01412ddea1c640dcbf3c2249dbc0aefa 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
<!-- 2. Initialize Cotter --> | |
<script> | |
var cotter = new Cotter({ | |
ApiKeyID: "<YOUR_API_KEY_ID>", // 👈 Specify your API KEY ID here | |
Styles: { | |
input_label: { | |
color: "red", // 👈 Specify your color here, use HEX, like #FFFFFF | |
}, | |
}, | |
}); | |
const redirectURL = localStorage.getItem("redirect_url_after_login") | |
cotter | |
// Choose what method of login do you want | |
// Sign In with Magic Link | |
.signInWithOTP() | |
// Send Magic Link via email | |
.showEmailForm() | |
.then(payload => { | |
// PRINT THE PAYLOAD TO THE CONSOLE | |
console.log(payload) | |
// save OAuth token | |
localStorage.setItem("user_session", JSON.stringify(payload)); | |
// redirect to location before login page | |
const redirectURL = localStorage.getItem("redirect_url_after_login") | |
if(!!redirectURL) window.location.href = redirectURL | |
else window.location.href = "/protected"; | |
}) | |
.catch(err => { | |
// handle error | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment