fix(logging): updated entire server side to the new logging system
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import {eq, sql} from "drizzle-orm";
|
||||
import {db} from "../../../../../database/dbclient.js";
|
||||
import {users} from "../../../../../database/schema/users.js";
|
||||
import {log} from "../../../logger/logger.js";
|
||||
import {createLog} from "../../../logger/logger.js";
|
||||
import {createPassword} from "../../utils/createPassword.js";
|
||||
|
||||
const blacklistedTokens = new Set();
|
||||
@@ -17,10 +17,9 @@ function isTokenBlacklisted(token: string) {
|
||||
|
||||
export const updateProfile = async (user: any, data: any, token: string) => {
|
||||
if (isTokenBlacklisted(token)) {
|
||||
log.warn(`${user.username} is trying to use a black listed token`);
|
||||
createLog("warn", user.username, "auth", `${user.username} is trying to use a black listed token`);
|
||||
throw Error("This token was already used");
|
||||
}
|
||||
log.info(`${user.user_id}`);
|
||||
|
||||
//re salt and encrypt the password
|
||||
try {
|
||||
@@ -33,6 +32,11 @@ export const updateProfile = async (user: any, data: any, token: string) => {
|
||||
|
||||
blacklistToken(token);
|
||||
} catch (error) {
|
||||
log.error(error, "There was an error updating the users profile");
|
||||
createLog(
|
||||
"error",
|
||||
user.username,
|
||||
"auth",
|
||||
`Error: ${JSON.stringify(error)}, "There was an error updating the users profile"`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user