|
|
|
@ -10,11 +10,11 @@ const _ = require('lodash');
|
|
|
|
|
/**
|
|
|
|
|
* Get Auth Status
|
|
|
|
|
*/
|
|
|
|
|
router.get('/', function(req, res) {
|
|
|
|
|
router.get('/', function (req, res) {
|
|
|
|
|
var token = req.headers['x-access-token'];
|
|
|
|
|
if (!token) return res.status(401).send({ auth: false, message: 'No token provided.' });
|
|
|
|
|
|
|
|
|
|
jwt.verify(token, 'super-secret-string', function(err, decoded) {
|
|
|
|
|
jwt.verify(token, 'super-secret-string', function (err, decoded) {
|
|
|
|
|
if (err)
|
|
|
|
|
return res.status(500).send({ auth: false, message: 'Failed to authenticate token.' });
|
|
|
|
|
res.status(200).send(decoded);
|
|
|
|
@ -24,7 +24,7 @@ router.get('/', function(req, res) {
|
|
|
|
|
/**
|
|
|
|
|
* Get Auth Status
|
|
|
|
|
*/
|
|
|
|
|
router.get('/status', function(req, res) {
|
|
|
|
|
router.get('/status', function (req, res) {
|
|
|
|
|
if (req.session.user) {
|
|
|
|
|
let session = req.session;
|
|
|
|
|
res.json({
|
|
|
|
@ -42,7 +42,7 @@ router.get('/status', function(req, res) {
|
|
|
|
|
/**
|
|
|
|
|
* Login Member and return token
|
|
|
|
|
*/
|
|
|
|
|
router.post('/login', function(req, res) {
|
|
|
|
|
router.post('/login', function (req, res) {
|
|
|
|
|
fs.readJson('site/folks.json').then(folks => {
|
|
|
|
|
let found = _.find(folks, { handle: req.body.handle });
|
|
|
|
|
if (found) {
|
|
|
|
|