Last active
January 24, 2018 13:33
-
-
Save singhpratyush/88eb91328dcebc6a6b8634ec4a6f9533 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import steem from 'steem'; | |
// Get the form values | |
let username = document.getElementById('steem-username').value; | |
let privatePostingKey = document.getEmenentById('steem-posting-key').value; | |
// Get user details | |
steem.api.getAccounts([username], (err, result) => { | |
if (err) { | |
// Something went wrong | |
} | |
if (result.length === 0) { | |
// No such user | |
} | |
// Get the public key | |
let publicPostingKey = result[0].posting.key_auths[0][0]; | |
// Try logging in | |
let loginSuccess = false; | |
try { | |
loginSuccess = steem.auth.wifIsValid(privatePostingKey, publicPostingKey); | |
} catch (e) { | |
// Failed log in | |
} | |
if (loginSuccess) { | |
// yay!! | |
} else { | |
// Wrong combination | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment