Deploy logs prod

This commit is contained in:
Vins 2024-04-24 18:23:31 +02:00
parent b5f4e23826
commit 1abab5dad2

View File

@ -57,7 +57,8 @@ export default class UserController extends ApiController {
//Whitelist feature //Whitelist feature
//Get user with contact //Get user with contact
const prismaUser = await this.userService.getByUid(user.uid, { contact: true, role: true, office_membership: true}); const prismaUser = await this.userService.getByUid(user.uid, { contact: true, role: true, office_membership: true});
console.log(prismaUser);
if (!prismaUser) { if (!prismaUser) {
this.httpNotFoundRequest(response, "user not found"); this.httpNotFoundRequest(response, "user not found");
@ -66,6 +67,7 @@ export default class UserController extends ApiController {
//Hydrate user to be able to use his contact //Hydrate user to be able to use his contact
const userHydrated = User.hydrate<User>(prismaUser, { strategy: "excludeAll" }); const userHydrated = User.hydrate<User>(prismaUser, { strategy: "excludeAll" });
console.log(userHydrated);
if (!userHydrated.contact?.email || userHydrated.contact?.email === "") { if (!userHydrated.contact?.email || userHydrated.contact?.email === "") {
this.httpUnauthorized(response, "Email not found"); this.httpUnauthorized(response, "Email not found");
@ -73,14 +75,18 @@ export default class UserController extends ApiController {
} }
let isSubscribed = false; let isSubscribed = false;
const subscriptions = await this.subscriptionsService.get({ where: { office_uid: userHydrated.office_membership?.uid } }); const subscriptions = await this.subscriptionsService.get({ where: { office_uid: userHydrated.office_membership?.uid } });
console.log(subscriptions);
if (!subscriptions || subscriptions.length === 0 || subscriptions[0]?.status === ESubscriptionStatus.INACTIVE) { if (!subscriptions || subscriptions.length === 0 || subscriptions[0]?.status === ESubscriptionStatus.INACTIVE) {
console.log("No subscription found");
isSubscribed = false; isSubscribed = false;
} }
else if (subscriptions[0]?.type === EType.Unlimited) { else if (subscriptions[0]?.type === EType.Unlimited) {
console.log("Unlimited subscription found");
isSubscribed = true; isSubscribed = true;
} else { } else {
console.log("Standard subscription found");
const hasSeat = await this.subscriptionsService.get({ const hasSeat = await this.subscriptionsService.get({
where: { status: ESubscriptionStatus.ACTIVE, seats: { some: { user_uid: userHydrated.uid } } }, where: { status: ESubscriptionStatus.ACTIVE, seats: { some: { user_uid: userHydrated.uid } } },
}); });
@ -116,9 +122,11 @@ export default class UserController extends ApiController {
await this.idNotService.updateOffice(user.office_uid); await this.idNotService.updateOffice(user.office_uid);
const payload = await this.authService.getUserJwtPayload(user.idNot); const payload = await this.authService.getUserJwtPayload(user.idNot);
console.log(payload);
if(!payload) return; if(!payload) return;
console.log(isSubscribed, userHydrated.role?.name);
if(!isSubscribed && userHydrated.role?.name === "admin" || userHydrated.role?.name === "super-admin"){ if(!isSubscribed && userHydrated.role?.name === "admin" || userHydrated.role?.name === "super-admin"){
const manageSubscriptionRulesEntity = await this.rulesGroupsService.get({ where: { uid: "94343601-04c8-44ef-afb9-3047597528a9" }, include: { rules: true } }); const manageSubscriptionRulesEntity = await this.rulesGroupsService.get({ where: { uid: "94343601-04c8-44ef-afb9-3047597528a9" }, include: { rules: true } });