unpkg/modules/actions/createAuth.js

19 lines
347 B
JavaScript
Raw Normal View History

2019-01-06 00:50:05 +00:00
import { createToken } from '../utils/auth';
2017-11-11 20:18:13 +00:00
2019-01-15 16:06:12 +00:00
const defaultScopes = {};
2017-11-11 20:18:13 +00:00
2019-01-06 00:50:05 +00:00
export default function createAuth(req, res) {
createToken(defaultScopes).then(
2017-11-11 20:18:13 +00:00
token => {
2018-02-18 02:00:56 +00:00
res.send({ token });
2017-11-11 20:18:13 +00:00
},
error => {
2018-02-18 02:00:56 +00:00
console.error(error);
2017-11-11 20:18:13 +00:00
res.status(500).send({
2018-12-17 17:38:05 +00:00
error: 'Unable to generate auth token'
2018-02-18 02:00:56 +00:00
});
2017-11-11 20:18:13 +00:00
}
2018-02-18 02:00:56 +00:00
);
2017-11-11 20:18:13 +00:00
}