slides-api
slides-api copied to clipboard
bug in storeToken()
in auth.js:
If the TOKEN_DIR exists, the error will always be thrown and the token will never be stored.
function storeToken(token) {
try {
fs.mkdirSync(TOKEN_DIR);
fs.writeFileSync(TOKEN_PATH, JSON.stringify(token));
} catch (err) {
if (err.code != 'EEXIST') return err;
}
console.log('Token stored to ' + TOKEN_PATH);
}
Should be:
function storeToken(token) {
try {
fs.mkdirSync(TOKEN_DIR);
} catch (err) {
if (err.code != 'EEXIST') return err;
}
try {
fs.writeFileSync(TOKEN_PATH, JSON.stringify(token));
} catch (err) {
return err;
}
console.log('Token stored to ' + TOKEN_PATH);
}
PRs welcome.