Deploy logs prod

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

View File

@ -58,6 +58,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);
if (!prismaUser) {
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
const userHydrated = User.hydrate<User>(prismaUser, { strategy: "excludeAll" });
console.log(userHydrated);
if (!userHydrated.contact?.email || userHydrated.contact?.email === "") {
this.httpUnauthorized(response, "Email not found");
@ -74,13 +76,17 @@ export default class UserController extends ApiController {
let isSubscribed = false;
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) {
console.log("No subscription found");
isSubscribed = false;
}
else if (subscriptions[0]?.type === EType.Unlimited) {
console.log("Unlimited subscription found");
isSubscribed = true;
} else {
console.log("Standard subscription found");
const hasSeat = await this.subscriptionsService.get({
where: { status: ESubscriptionStatus.ACTIVE, seats: { some: { user_uid: userHydrated.uid } } },
});
@ -117,8 +123,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);
if(!payload) return;
console.log(isSubscribed, userHydrated.role?.name);
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 } });