Merge branch 'preprod' into staging
This commit is contained in:
commit
ff10fbd69c
@ -31,7 +31,8 @@ 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"];
|
||||
const code = req.params["code"];
|
||||
|
||||
if (!code) throw new Error("code is required");
|
||||
|
||||
const idNotToken = await this.idNotService.getIdNotToken(code);
|
||||
@ -41,7 +42,7 @@ export default class UserController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = await this.idNotService.getOrCreateUser(idNotToken);
|
||||
const user = await this.idNotService.getOrCreateUser(idNotToken);
|
||||
|
||||
if (!user) {
|
||||
this.httpUnauthorized(response, "User not found");
|
||||
@ -52,7 +53,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 });
|
||||
const prismaUser = await this.userService.getByUid(user.uid, { contact: true, role: true, office_membership: true });
|
||||
|
||||
if (!prismaUser) {
|
||||
this.httpNotFoundRequest(response, "user not found");
|
||||
@ -60,13 +61,15 @@ 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");
|
||||
return;
|
||||
}
|
||||
let isSubscribed = await this.subscriptionsService.isUserSubscribed(user.uid, userHydrated.office_membership?.uid!);
|
||||
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);
|
||||
@ -103,7 +106,7 @@ export default class UserController extends ApiController {
|
||||
isSubscribed = true;
|
||||
}
|
||||
|
||||
if (!isSubscribed) {
|
||||
if (!isSubscribed) {
|
||||
this.httpUnauthorized(response, "User not subscribed");
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user