main
AdamSBlack 2022-05-01 23:35:55 +01:00
parent 7ff8d5f190
commit f68f76c237
No known key found for this signature in database
GPG Key ID: E66E51A97D150E28
4 changed files with 14 additions and 26 deletions

View File

@ -1,4 +1,3 @@
import authentication from './authentication';
import { Accounts } from '../../models';

View File

@ -7,8 +7,7 @@ export async function SetResearchStatus(userId, status) {
}
export async function GetResearchStatus(userId) {
return Accounts.findOne({where: {id: userId}, attributes: ['research_enabled']})
return Accounts.findOne({ where: { id: userId }, attributes: ['research_enabled'] });
}
export default null;

View File

@ -1,5 +1,4 @@
import express from 'express';
import log4js from 'log4js';
import admin from './admin';
import auth from './auth';

View File

@ -1,34 +1,25 @@
import bodyParser from 'body-parser';
import crypto from 'crypto';
import dirTree from 'directory-tree';
import express from 'express';
import log4js from 'log4js';
import { requireAuthenticated } from '../../../middlewares/authentication';
import { SetResearchStatus, GetResearchStatus } from '../../../controllers/user/settings';
const logger = log4js.getLogger();
// /api/devices
const router = express.Router();
router.patch('/research/:enabled', requireAuthenticated, async (req, res) => {
const { enabled } = req.params;
if (!enabled) { res.json({ bad: true }); }
const doEnable = enabled === 'true';
const accountId = req.account.id;
const update = await SetResearchStatus(req.account.id, doEnable);
return res.json({ success: true, data: req.account });
});
const { enabled } = req.params;
if (!enabled) { res.json({ bad: true }); }
const doEnable = enabled === 'true';
router.get('/research/', requireAuthenticated, async (req, res) => {
const accountId = req.account.id;
const update = await GetResearchStatus(req.account.id);
return res.json({ success: true, data: update });
});
await SetResearchStatus(req.account.id, doEnable);
return res.json({ success: true, data: req.account });
});
router.get('/research/', requireAuthenticated, async (req, res) => {
const update = await GetResearchStatus(req.account.id);
return res.json({ success: true, data: update });
});
export default router;