logger
parent
be94357332
commit
56a854fcb1
|
@ -45,11 +45,11 @@ export async function getToken(code, scope) {
|
|||
return { error: true, ...AUTH_OAUTH_ERR_GOOGLE_FAILED_TOKEN_FETCH };
|
||||
}
|
||||
|
||||
console.log(accessToken);
|
||||
logger.log(`accessToken: ${accessToken}`);
|
||||
|
||||
const id = jsonwebtoken.decode(accessToken.token.id_token);
|
||||
|
||||
console.log(id);
|
||||
logger.log(`jsonwebtoken.${id}`);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ async function getDrives(dongleId, includeDeleted, includeMeta) {
|
|||
|
||||
async function getDrive(identifier) {
|
||||
const drive = await orm.models.drives.findOne({ where: { identifier } });
|
||||
console.log(drive);
|
||||
logger.log(drive);
|
||||
|
||||
if (drive.dataValues) return drive.dataValues;
|
||||
return null;
|
||||
|
@ -273,7 +273,7 @@ async function updateOrCreateDrive(dongleId, identifier, data) {
|
|||
logger.info('updateOrCreate Drive', dongleId, identifier, data);
|
||||
const check = await orm.models.drives.findOne({ where: { dongle_id: dongleId, identifier } });
|
||||
|
||||
console.log('checking for existing drive....', check);
|
||||
logger.log('checking for existing drive....', check);
|
||||
|
||||
if (check) {
|
||||
return orm.models.drives.update(
|
||||
|
|
|
@ -17,7 +17,7 @@ export async function getAccountFromEmail(email) {
|
|||
}
|
||||
|
||||
export async function _dirtyCreateAccount(email, password, created, admin) {
|
||||
console.log('creating acount: ', email, password, created, admin);
|
||||
logger.log('creating acount: ', email, password, created, admin);
|
||||
return orm.models.accounts.create({
|
||||
email, password, created, admin,
|
||||
});
|
||||
|
|
|
@ -44,8 +44,6 @@ router.get('/user/:userId/get/devices', runAsyncWrapper(async (req, res) => {
|
|||
}));
|
||||
|
||||
router.get('/user/', runAsyncWrapper(async (req, res) => {
|
||||
console.warn('PROCESSED');
|
||||
|
||||
return res.status(200).json({ success: true, data: await controllers.users.getAllUsers() });
|
||||
}));
|
||||
|
||||
|
@ -71,7 +69,6 @@ router.get('/device/:dongle_id/pair/:user_id', runAsyncWrapper(async (req, res)
|
|||
|
||||
router.get('/device', runAsyncWrapper(async (req, res) => {
|
||||
const filteredDevices = await controllers.devices.getAllDevicesFiltered();
|
||||
console.log('fil', filteredDevices);
|
||||
return res.status(200).json({ success: true, data: filteredDevices });
|
||||
}));
|
||||
|
||||
|
|
|
@ -268,10 +268,9 @@ async function upload(req, res) {
|
|||
const drive = await deviceController.getDriveFromidentifier(dongleId, driveName).catch((err)=>{
|
||||
logger.warn("drive failed to make", err)
|
||||
})
|
||||
console.log("drive value", drive)
|
||||
console.log("drive name:", driveName)
|
||||
|
||||
|
||||
logger.log("drive value", drive)
|
||||
logger.log("drive name:", driveName)
|
||||
|
||||
if (drive === undefined || drive === null) {
|
||||
logger.info("CREATING NEW DRIVE")
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import express from 'express';
|
||||
import jsonwebtoken from 'jsonwebtoken';
|
||||
import { getURL, getToken } from '../../../controllers/authentication/oauth/google';
|
||||
import authenticationController from '../../../controllers/authentication';
|
||||
import log4js from 'log4js';
|
||||
|
||||
const router = express.Router();
|
||||
const logger = log4js.getLogger('default');
|
||||
|
||||
async function isAuthenticated(req, res, next) {
|
||||
const account = await authenticationController.getAuthenticatedAccount(req);
|
||||
|
@ -22,14 +23,13 @@ async function isAuthenticated(req, res, next) {
|
|||
}
|
||||
|
||||
router.get('/authentication/oauth/callback', async (req, res) => {
|
||||
console.log(req.query);
|
||||
|
||||
logger.log(req.query);
|
||||
res.json(await getToken(req.query.code, req.query.scope));
|
||||
});
|
||||
|
||||
router.get('/authentication/oauth/:provider', async (req, res) => {
|
||||
const { provider } = req.params;
|
||||
console.log('provider', provider);
|
||||
logger.log('provider', provider);
|
||||
let url;
|
||||
switch (provider) {
|
||||
case 'google':
|
||||
|
@ -48,9 +48,7 @@ router.get('/authentication/oauth/:provider', async (req, res) => {
|
|||
});
|
||||
|
||||
router.get('/authentication/oauth/pair/:provider', isAuthenticated, async (req, res) => {
|
||||
|
||||
|
||||
|
||||
res.status(200);
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
|
|
@ -3,9 +3,13 @@ import crypto from 'crypto';
|
|||
import dirTree from 'directory-tree';
|
||||
import bodyParser from 'body-parser';
|
||||
import deviceSchema from '../../schema/routes/devices';
|
||||
import log4js from 'log4js';
|
||||
|
||||
import deviceController from '../../controllers/devices';
|
||||
import authenticationController from '../../controllers/authentication';
|
||||
|
||||
const logger = log4js.getLogger('default');
|
||||
|
||||
const router = express.Router();
|
||||
async function isAuthenticated(req, res, next) {
|
||||
const account = await authenticationController.getAuthenticatedAccount(req);
|
||||
|
@ -50,7 +54,7 @@ router.put('/retropilot/0/device/:dongle_id/', [isAuthenticated, bodyParser.json
|
|||
}
|
||||
|
||||
const { body } = req;
|
||||
console.log(deviceSchema.MutateDevice.isValid(body));
|
||||
logger.log(deviceSchema.MutateDevice.isValid(body));
|
||||
});
|
||||
|
||||
router.get('/retropilot/0/device/:dongle_id/drives/:drive_identifier/segment', isAuthenticated, async (req, res) => {
|
||||
|
|
|
@ -27,7 +27,7 @@ function runAsyncWrapper(callback) {
|
|||
router.post('/useradmin/auth', bodyParser.urlencoded({ extended: true }), runAsyncWrapper(async (req, res) => {
|
||||
const signIn = await authenticationController.signIn(req.body.email, req.body.password);
|
||||
|
||||
console.log(signIn);
|
||||
logger.log(signIn);
|
||||
|
||||
if (signIn.success) {
|
||||
res.cookie('jwt', signIn.jwt);
|
||||
|
@ -130,7 +130,7 @@ router.post('/useradmin/register/token', bodyParser.urlencoded({ extended: true
|
|||
console.error(error);
|
||||
}
|
||||
|
||||
console.log(result);
|
||||
logger.log(result);
|
||||
|
||||
if (result.dataValues) {
|
||||
logger.info(`USERADMIN REGISTRATION - created new account #${result.lastID} with email ${email}`);
|
||||
|
|
|
@ -26,6 +26,7 @@ process.on('unhandledRejection', (error, p) => {
|
|||
console.log(error.promise, p);
|
||||
console.dir(error.stack);
|
||||
});
|
||||
|
||||
log4js.configure({
|
||||
appenders: { logfile: { type: 'file', filename: 'server.log' }, out: { type: 'console' } /* {type: "file", filename: "server1.log"} */ },
|
||||
categories: { default: { appenders: ['out', 'logfile'], level: 'info' } },
|
||||
|
|
Loading…
Reference in New Issue