UNPKG

botpress

Version:

The world's first CMS for bots. Easily create, manage and extend chatbots.

45 lines (38 loc) 1.66 kB
'use strict'; function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } module.exports = (bp, app) => { app.get('/api/auth/info', (() => { var _ref = _asyncToGenerator(function* (req, res) { bp.stats.track('api', 'auth', 'info'); res.json(bp.security.getAuthenticationInfo()); }); return function (_x, _x2) { return _ref.apply(this, arguments); }; })()); app.post('/api/auth/refresh_token', (() => { var _ref2 = _asyncToGenerator(function* (req, res) { bp.stats.track('api', 'auth', 'refresh_token'); const result = yield bp.security.refreshToken(req.headers.authorization); if (result.success) { res.send(result.token); } else { res.status(400).send(result.reason); } }); return function (_x3, _x4) { return _ref2.apply(this, arguments); }; })()); app.post('/api/login', (() => { var _ref3 = _asyncToGenerator(function* (req, res) { bp.stats.track('api', 'auth', 'login'); const result = yield bp.security.login(req.body.user, req.body.password, req.ip); res.send(result); }); return function (_x5, _x6) { return _ref3.apply(this, arguments); }; })()); }; //# sourceMappingURL=anonymous.js.map