Fixed login

This commit is contained in:
Vins 2024-04-12 16:11:00 +02:00
parent 743934120e
commit 79edaaefa4

View File

@ -37,14 +37,14 @@ export default class UserController extends ApiController {
if (!code) throw new Error("code is required");
const idNotToken = await this.idNotService.getIdNotToken(code);
const idNotToken = await this.idNotService.getIdNotToken(code);
if (!idNotToken) {
this.httpValidationError(response, "IdNot token undefined");
return;
}
const user = await this.idNotService.getOrCreateUser(idNotToken);
const user = await this.idNotService.getOrCreateUser(idNotToken);
if (!user) {
this.httpUnauthorized(response, "User not found");
@ -55,7 +55,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 });
const prismaUser = await this.userService.getByUid(user.uid, { contact: true, role: true });
if (!prismaUser) {
this.httpNotFoundRequest(response, "user not found");
@ -63,7 +63,7 @@ export default class UserController extends ApiController {
}
//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" });
if (!userHydrated.contact?.email || userHydrated.contact?.email === "") {
this.httpUnauthorized(response, "Email not found");
@ -71,14 +71,12 @@ export default class UserController extends ApiController {
}
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 } });
if (!subscriptions || subscriptions.length === 0 || subscriptions[0]?.status === ESubscriptionStatus.INACTIVE) {
isSubscribed = false;
return;
}
if (subscriptions[0]?.type === EType.Unlimited) {
else if (subscriptions[0]?.type === EType.Unlimited) {
isSubscribed = true;
} else {
const hasSeat = await this.subscriptionsService.get({