Skip to content

Instantly share code, notes, and snippets.

@singhpratyush
Last active January 24, 2018 13:33
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 singhpratyush/88eb91328dcebc6a6b8634ec4a6f9533 to your computer and use it in GitHub Desktop.
Save singhpratyush/88eb91328dcebc6a6b8634ec4a6f9533 to your computer and use it in GitHub Desktop.
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