UNPKG

o3-panther-cli

Version:
23 lines (22 loc) 677 B
const path = require('path'); const request = require('request-promise').defaults({ jar: true }); const cnf = require(path.resolve(process.cwd(), 'o3.json')); module.exports = (info) => { var options = { method: 'POST', uri: (info.https ? 'https://' : 'http://') + info.uri, form: { username: info.user, password: info.pass }, simple: false, headers: { 'content-type': 'application/x-www-form-urlencoded' } }; return request(options).then((data) => { if (data.indexOf('Found. Redirecting to') < 0) { throw new Error('Login failed'); } }); }