A few days ago I wrote about the problems of the steem development ecosystem and notably the lack of examples/documentation on how to do things in this article.
It thought about how I could solve these problems and after a few days, and talking with @scipio about it, I created steemsnippets.
Steemsnippets is a github repository with small snippets of code(aka very small functions for some specific use cases) To interact with steem.
To give you an idea for now the repository contains those snippets :
All of them using steemjs but I plan to expand it to other languages very soon.
Disclamer : I use pieces of code that worked for me but there may be ways to improve them, if you do find some ways to do that, don't hesitate to submit a pull request :)
The core idea behind this is to ease the pain and googling of the future programmers. On steemsnippets they can find ready to use functions that they can add in their workflow. Which means less time searching and more time creating awesome applications around steem.
I obviously accept external pull requests. Look up github's documentation on How to create a pull request on how to do so. But make sure you follow these rules :
Don't forget that your contributions can be submitted to utopian.io for a reward so don't forget to look there as well :)
This snippet can be found here
/**
* Tests if an username/password pair is correct
* @param {String} username - username of the account
* @param {String} password - password of the account
* @return {boolean} valid - True of the password is correct, false if not (or if the account doesn't exists)
*/
function login_using_password(username, password) {
// Get the private posting key
var wif = steem.auth.toWif(username, password, 'posting');
steem.api.getAccounts([username], function (err, result) {
// check if the account exists
if (result.length !== 0) {
// get the public posting key
var pubWif = result[0].posting.key_auths[0][0];
var valid = false;
try {
// Check if the private key matches the public one.
valid = steem.auth.wifIsValid(wif, pubWif)
} catch (e) {
}
return valid;
}
return false;
});
}