unpkg/modules/actions/createAuth.js

25 lines
399 B
JavaScript
Raw Normal View History

2018-02-18 02:00:56 +00:00
const AuthAPI = require("../AuthAPI");
2017-11-11 20:18:13 +00:00
2017-11-12 07:30:41 +00:00
const defaultScopes = {
2017-11-11 20:18:13 +00:00
blacklist: {
read: true
}
2018-02-18 02:00:56 +00:00
};
2017-11-11 20:18:13 +00:00
function createAuth(req, res) {
2017-11-12 07:30:41 +00:00
AuthAPI.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({
2017-11-25 21:25:01 +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
}
2018-02-18 02:00:56 +00:00
module.exports = createAuth;