Removed logs

This commit is contained in:
Vins 2024-05-06 16:46:35 +02:00
parent 3a2e854238
commit c5ce26a8a0
4 changed files with 9 additions and 38 deletions

View File

@ -31,26 +31,17 @@ export default class UserController extends ApiController {
@Post("/api/v1/idnot/user/:code")
protected async getUserInfosFromIdnot(req: Request, response: Response) {
try {
const code = req.params["code"];
console.log("code", code);
const code = req.params["code"];
if (!code) throw new Error("code is required");
const idNotToken = await this.idNotService.getIdNotToken(code);
console.log("idNotToken", idNotToken);
if (!idNotToken) {
this.httpValidationError(response, "IdNot token undefined");
return;
}
const user = await this.idNotService.getOrCreateUser(idNotToken);
console.log("user", user);
const user = await this.idNotService.getOrCreateUser(idNotToken);
if (!user) {
this.httpUnauthorized(response, "User not found");
@ -61,9 +52,7 @@ export default class UserController extends ApiController {
//Whitelist feature
//Get user with contact
const prismaUser = await this.userService.getByUid(user.uid, { contact: true, role: true, office_membership: true });
console.log("prismaUser", prismaUser);
const prismaUser = await this.userService.getByUid(user.uid, { contact: true, role: true, office_membership: true });
if (!prismaUser) {
this.httpNotFoundRequest(response, "user not found");
@ -71,17 +60,13 @@ export default class UserController extends ApiController {
}
//Hydrate user to be able to use his contact
const userHydrated = User.hydrate<User>(prismaUser, { strategy: "excludeAll" });
console.log("userHydrated", userHydrated);
const userHydrated = User.hydrate<User>(prismaUser, { strategy: "excludeAll" });
if (!userHydrated.contact?.email || userHydrated.contact?.email === "") {
this.httpUnauthorized(response, "Email not found");
return;
}
let isSubscribed = await this.subscriptionsService.isUserSubscribed(user.uid, userHydrated.office_membership?.uid!);
console.log("isSubscribed", isSubscribed);
let isSubscribed = await this.subscriptionsService.isUserSubscribed(user.uid, userHydrated.office_membership?.uid!);
//Check if user is whitelisted
// const isWhitelisted = await this.whitelistService.getByEmail(userHydrated.contact!.email);
@ -98,12 +83,10 @@ export default class UserController extends ApiController {
await this.idNotService.updateOffice(user.office_uid);
const payload = await this.authService.getUserJwtPayload(user.idNot);
console.log("payload", payload);
if (!payload) return;
if (!isSubscribed && (userHydrated.role?.name === "admin" || userHydrated.role?.name === "super-admin")) {
console.log("userHydrated.role", userHydrated.role);
const manageSubscriptionRulesEntity = await this.rulesGroupsService.get({
where: { uid: "94343601-04c8-44ef-afb9-3047597528a9" },
@ -120,9 +103,7 @@ export default class UserController extends ApiController {
isSubscribed = true;
}
if (!isSubscribed) {
console.log("User not subscribed");
if (!isSubscribed) {
this.httpUnauthorized(response, "User not subscribed");
return;
}

View File

@ -14,9 +14,7 @@ const storage = multer.memoryStorage();
(async () => {
try {
const variables = await Container.get(BackendVariables).validate();
console.log(variables);
const variables = await Container.get(BackendVariables).validate();
const port = variables.APP_PORT;
const rootUrl = variables.APP_ROOT_URL;
const label = variables.APP_LABEL ?? "Unknown Service";

View File

@ -120,22 +120,16 @@ export default class IdNotService extends BaseService {
redirect_uri: this.variables.IDNOT_REDIRECT_URL,
code: code,
grant_type: "authorization_code",
});
console.log(this.variables.IDNOT_BASE_URL + this.variables.IDNOT_CONNEXION_URL + "?" + query.toString());
});
const token = await fetch(this.variables.IDNOT_BASE_URL + this.variables.IDNOT_CONNEXION_URL + "?" + query, { method: "POST" });
console.log(token);
if(token.status !== 200) console.error(await token.text());
const decodedToken = (await token.json()) as IIdNotToken;
console.log(decodedToken);
const decodedIdToken = jwt.decode(decodedToken.id_token) as IdNotJwtPayload;
console.log(decodedIdToken);
const decodedIdToken = jwt.decode(decodedToken.id_token) as IdNotJwtPayload;
return decodedIdToken;

View File

@ -38,7 +38,6 @@ export default class OfficerRibService extends BaseService {
}
public async createOrUpdate(officeId: string, file: Express.Multer.File) {
console.log("officeId", officeId);
const key = path.join(this.variables.ENV, officeId, file.originalname);
const uploadParams = {
@ -47,7 +46,6 @@ export default class OfficerRibService extends BaseService {
Body: file.buffer, // Example: fs.createReadStream('/path/to/file')
ACL: "public-read", // Optional: Set the ACL if needed
};
console.log("uploadParams", uploadParams);
return new Promise<string>((resolve, reject) => {
this.s3.putObject(uploadParams, (err, data) => {