Fixed logging

logging
AnzeBlaBla 2022-11-18 18:01:30 +01:00
parent 401dc44348
commit 99f69e141e
2 changed files with 8 additions and 8 deletions

View File

@ -14,7 +14,7 @@ router.get('/login', function (req, res, next) {
router.post('/login', async (req, res, next) => { router.post('/login', async (req, res, next) => {
const { email, password } = req.body; const { email, password } = req.body;
console.log("/login: " + req.body); console.log("/login: " + JSON.stringify(req.body));
const r = await db.query('SELECT * FROM users WHERE email=$1', [email]); const r = await db.query('SELECT * FROM users WHERE email=$1', [email]);
if (r.rowCount < 1 || r.rows[0].password !== password) { if (r.rowCount < 1 || r.rows[0].password !== password) {
res.locals.errormsg = 'Wrong credentials'; res.locals.errormsg = 'Wrong credentials';
@ -35,7 +35,7 @@ router.get('/register', function (req, res, next) {
router.post('/register', async (req, res, next) => { router.post('/register', async (req, res, next) => {
const { email, nickname, password } = req.body; const { email, nickname, password } = req.body;
console.log("/register: " + req.body); console.log("/register: " + JSON.stringify(req.body));
const reg = /^[\w\.@]{4,40}$/; const reg = /^[\w\.@]{4,40}$/;

View File

@ -7,7 +7,7 @@ const db = require('../db');
const router = express.Router(); const router = express.Router();
async function create_message(channel_id, msg, author) { async function create_message(channel_id, msg, author) {
console.log("create_message: " + channel_id + msg + author); console.log("create_message: " + channel_id + " - " + msg + " - " + author);
let r = await db.query('SELECT * FROM channels WHERE id=$1', [channel_id]); let r = await db.query('SELECT * FROM channels WHERE id=$1', [channel_id]);
if (r.rowCount < 1) { if (r.rowCount < 1) {
@ -31,7 +31,7 @@ async function create_message(channel_id, msg, author) {
} }
async function list_channels(user) { async function list_channels(user) {
console.log("list_channel" + user); console.log("list_channel: " + JSON.stringify(user));
const r = await db.query('SELECT id, detail, private FROM channels WHERE private=FALSE UNION SELECT id, detail, private FROM channels, allowed_users WHERE id = channel_id AND user_email = $1', [user]); const r = await db.query('SELECT id, detail, private FROM channels WHERE private=FALSE UNION SELECT id, detail, private FROM channels, allowed_users WHERE id = channel_id AND user_email = $1', [user]);
return r.rows; return r.rows;
} }
@ -67,7 +67,7 @@ router.get('/channel/:id', async (req, res, next) => {
}); });
router.post('/new_channel', async (req, res, next) => { router.post('/new_channel', async (req, res, next) => {
console.log("/ne_chanell" + req.body); console.log("/new_chanell: " + JSON.stringify(req.body));
const { channelid, detail } = req.body; const { channelid, detail } = req.body;
const user = req.user.email; const user = req.user.email;
@ -84,7 +84,7 @@ router.post('/new_channel', async (req, res, next) => {
router.post('/new_message', async (req, res, next) => { router.post('/new_message', async (req, res, next) => {
const { msg, channelid } = req.body; const { msg, channelid } = req.body;
console.log("/new_message", + req.body); console.log("/new_message: ", + JSON.stringify(req.body));
const author = req.user.email; const author = req.user.email;
try { try {
@ -99,7 +99,7 @@ router.post('/new_message', async (req, res, next) => {
router.post('/invite', async (req, res, next) => { router.post('/invite', async (req, res, next) => {
const { channelid, user } = req.body; const { channelid, user } = req.body;
const logged_user = req.user.email; const logged_user = req.user.email;
console.log("/invite", + req.body); console.log("/invite: ", +JSON.stringify(req.body));
let r = await db.query('SELECT user_email FROM allowed_users WHERE user_email=$1 AND channel_id=$2', [logged_user, channelid]); let r = await db.query('SELECT user_email FROM allowed_users WHERE user_email=$1 AND channel_id=$2', [logged_user, channelid]);
@ -130,7 +130,7 @@ router.get('/broadcast', async (req, res, next) => {
}); });
router.post('/broadcast', async (req, res, next) => { router.post('/broadcast', async (req, res, next) => {
console.log("/broadcast", req.body); console.log("/broadcast: ", JSON.stringify(req.body));
let { msg } = req.body; let { msg } = req.body;
const author = req.user.email; const author = req.user.email;
const channels = Object.keys(req.cookies); const channels = Object.keys(req.cookies);