Logs
This commit is contained in:
parent
9fcdeff808
commit
2461036035
@ -31,17 +31,21 @@ export default class UserController extends ApiController {
|
|||||||
@Post("/api/v1/idnot/user/:code")
|
@Post("/api/v1/idnot/user/:code")
|
||||||
protected async getUserInfosFromIdnot(req: Request, response: Response) {
|
protected async getUserInfosFromIdnot(req: Request, response: Response) {
|
||||||
try {
|
try {
|
||||||
const code = req.params["code"];
|
const code = req.params["code"];
|
||||||
|
console.log("code", code);
|
||||||
|
|
||||||
if (!code) throw new Error("code is required");
|
if (!code) throw new Error("code is required");
|
||||||
|
|
||||||
const idNotToken = await this.idNotService.getIdNotToken(code);
|
const idNotToken = await this.idNotService.getIdNotToken(code);
|
||||||
|
console.log("idNotToken", idNotToken);
|
||||||
|
|
||||||
if (!idNotToken) {
|
if (!idNotToken) {
|
||||||
this.httpValidationError(response, "IdNot token undefined");
|
this.httpValidationError(response, "IdNot token undefined");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await this.idNotService.getOrCreateUser(idNotToken);
|
const user = await this.idNotService.getOrCreateUser(idNotToken);
|
||||||
|
console.log("user", user);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
this.httpUnauthorized(response, "User not found");
|
this.httpUnauthorized(response, "User not found");
|
||||||
@ -52,7 +56,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", prismaUser);
|
||||||
|
|
||||||
if (!prismaUser) {
|
if (!prismaUser) {
|
||||||
this.httpNotFoundRequest(response, "user not found");
|
this.httpNotFoundRequest(response, "user not found");
|
||||||
@ -60,13 +65,17 @@ 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", 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");
|
||||||
return;
|
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!);
|
||||||
|
console.log("isSubscribed", isSubscribed);
|
||||||
|
|
||||||
|
|
||||||
//Check if user is whitelisted
|
//Check if user is whitelisted
|
||||||
// const isWhitelisted = await this.whitelistService.getByEmail(userHydrated.contact!.email);
|
// const isWhitelisted = await this.whitelistService.getByEmail(userHydrated.contact!.email);
|
||||||
@ -103,7 +112,9 @@ export default class UserController extends ApiController {
|
|||||||
isSubscribed = true;
|
isSubscribed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSubscribed) {
|
if (!isSubscribed) {
|
||||||
|
console.log("User not subscribed");
|
||||||
|
|
||||||
this.httpUnauthorized(response, "User not subscribed");
|
this.httpUnauthorized(response, "User not subscribed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user