Removed logs
This commit is contained in:
parent
3a2e854238
commit
c5ce26a8a0
@ -31,26 +31,17 @@ 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");
|
||||||
@ -61,9 +52,7 @@ 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");
|
||||||
@ -71,17 +60,13 @@ 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);
|
||||||
@ -98,12 +83,10 @@ 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", payload);
|
|
||||||
|
|
||||||
if (!payload) return;
|
if (!payload) return;
|
||||||
|
|
||||||
if (!isSubscribed && (userHydrated.role?.name === "admin" || userHydrated.role?.name === "super-admin")) {
|
if (!isSubscribed && (userHydrated.role?.name === "admin" || userHydrated.role?.name === "super-admin")) {
|
||||||
console.log("userHydrated.role", userHydrated.role);
|
|
||||||
|
|
||||||
const manageSubscriptionRulesEntity = await this.rulesGroupsService.get({
|
const manageSubscriptionRulesEntity = await this.rulesGroupsService.get({
|
||||||
where: { uid: "94343601-04c8-44ef-afb9-3047597528a9" },
|
where: { uid: "94343601-04c8-44ef-afb9-3047597528a9" },
|
||||||
@ -120,9 +103,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,7 @@ const storage = multer.memoryStorage();
|
|||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const variables = await Container.get(BackendVariables).validate();
|
const variables = await Container.get(BackendVariables).validate();
|
||||||
console.log(variables);
|
|
||||||
|
|
||||||
const port = variables.APP_PORT;
|
const port = variables.APP_PORT;
|
||||||
const rootUrl = variables.APP_ROOT_URL;
|
const rootUrl = variables.APP_ROOT_URL;
|
||||||
const label = variables.APP_LABEL ?? "Unknown Service";
|
const label = variables.APP_LABEL ?? "Unknown Service";
|
||||||
|
@ -120,22 +120,16 @@ export default class IdNotService extends BaseService {
|
|||||||
redirect_uri: this.variables.IDNOT_REDIRECT_URL,
|
redirect_uri: this.variables.IDNOT_REDIRECT_URL,
|
||||||
code: code,
|
code: code,
|
||||||
grant_type: "authorization_code",
|
grant_type: "authorization_code",
|
||||||
});
|
});
|
||||||
console.log(this.variables.IDNOT_BASE_URL + this.variables.IDNOT_CONNEXION_URL + "?" + query.toString());
|
|
||||||
|
|
||||||
|
|
||||||
const token = await fetch(this.variables.IDNOT_BASE_URL + this.variables.IDNOT_CONNEXION_URL + "?" + query, { method: "POST" });
|
const token = await fetch(this.variables.IDNOT_BASE_URL + this.variables.IDNOT_CONNEXION_URL + "?" + query, { method: "POST" });
|
||||||
console.log(token);
|
|
||||||
|
|
||||||
if(token.status !== 200) console.error(await token.text());
|
if(token.status !== 200) console.error(await token.text());
|
||||||
|
|
||||||
const decodedToken = (await token.json()) as IIdNotToken;
|
const decodedToken = (await token.json()) as IIdNotToken;
|
||||||
console.log(decodedToken);
|
|
||||||
|
|
||||||
|
|
||||||
const decodedIdToken = jwt.decode(decodedToken.id_token) as IdNotJwtPayload;
|
const decodedIdToken = jwt.decode(decodedToken.id_token) as IdNotJwtPayload;
|
||||||
console.log(decodedIdToken);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return decodedIdToken;
|
return decodedIdToken;
|
||||||
|
@ -38,7 +38,6 @@ export default class OfficerRibService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async createOrUpdate(officeId: string, file: Express.Multer.File) {
|
public async createOrUpdate(officeId: string, file: Express.Multer.File) {
|
||||||
console.log("officeId", officeId);
|
|
||||||
const key = path.join(this.variables.ENV, officeId, file.originalname);
|
const key = path.join(this.variables.ENV, officeId, file.originalname);
|
||||||
|
|
||||||
const uploadParams = {
|
const uploadParams = {
|
||||||
@ -47,7 +46,6 @@ export default class OfficerRibService extends BaseService {
|
|||||||
Body: file.buffer, // Example: fs.createReadStream('/path/to/file')
|
Body: file.buffer, // Example: fs.createReadStream('/path/to/file')
|
||||||
ACL: "public-read", // Optional: Set the ACL if needed
|
ACL: "public-read", // Optional: Set the ACL if needed
|
||||||
};
|
};
|
||||||
console.log("uploadParams", uploadParams);
|
|
||||||
|
|
||||||
return new Promise<string>((resolve, reject) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
this.s3.putObject(uploadParams, (err, data) => {
|
this.s3.putObject(uploadParams, (err, data) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user