logs
This commit is contained in:
parent
98ecd40434
commit
577edf5566
@ -35,15 +35,11 @@ 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"];
|
||||
console.log("code", code);
|
||||
|
||||
const code = req.params["code"];
|
||||
|
||||
if (!code) throw new Error("code is required");
|
||||
|
||||
const idNotToken = await this.idNotService.getIdNotToken(code);
|
||||
console.log("idNotToken", idNotToken);
|
||||
|
||||
const idNotToken = await this.idNotService.getIdNotToken(code);
|
||||
|
||||
if (!idNotToken) {
|
||||
this.httpValidationError(response, "IdNot token undefined");
|
||||
@ -77,9 +73,7 @@ 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", subscriptions);
|
||||
|
||||
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;
|
||||
@ -122,24 +116,16 @@ export default class UserController extends ApiController {
|
||||
|
||||
await this.idNotService.updateOffice(user.office_uid);
|
||||
|
||||
const payload = await this.authService.getUserJwtPayload(user.idNot);
|
||||
console.log("payload", payload);
|
||||
|
||||
const payload = await this.authService.getUserJwtPayload(user.idNot);
|
||||
if(!payload) return;
|
||||
|
||||
|
||||
if(!isSubscribed && userHydrated.role?.name === "admin" || userHydrated.role?.name === "super-admin"){
|
||||
const manageSubscriptionRulesEntity = await this.rulesGroupsService.get({ where: { name: "Gestion de l'abonnement" }, include: { rules: true } });
|
||||
console.log("manageSubscriptionRulesEntity", manageSubscriptionRulesEntity);
|
||||
|
||||
const manageSubscriptionRules = RulesGroup.hydrateArray<RulesGroup>(manageSubscriptionRulesEntity, { strategy: "excludeAll" });
|
||||
console.log("manageSubscriptionRules", manageSubscriptionRules);
|
||||
|
||||
const manageSubscriptionRulesEntity = await this.rulesGroupsService.get({ where: { name: "Gestion de l'abonnement" }, include: { rules: true } });
|
||||
const manageSubscriptionRules = RulesGroup.hydrateArray<RulesGroup>(manageSubscriptionRulesEntity, { strategy: "excludeAll" });
|
||||
if(!manageSubscriptionRules[0]) return;
|
||||
|
||||
payload.rules = manageSubscriptionRules[0].rules!.map((rule) => rule.name) || [];
|
||||
console.log("payload with subscription rules", payload);
|
||||
|
||||
payload.rules = manageSubscriptionRules[0].rules!.map((rule) => rule.name) || [];
|
||||
isSubscribed = true;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@ const storage = multer.memoryStorage();
|
||||
(async () => {
|
||||
try {
|
||||
const variables = await Container.get(BackendVariables).validate();
|
||||
console.log(variables.DATABASE_NAME);
|
||||
|
||||
const port = variables.APP_PORT;
|
||||
const rootUrl = variables.APP_ROOT_URL;
|
||||
const label = variables.APP_LABEL ?? "Unknown Service";
|
||||
|
@ -121,22 +121,15 @@ export default class IdNotService extends BaseService {
|
||||
code: code,
|
||||
grant_type: "authorization_code",
|
||||
});
|
||||
console.log(this.variables.IDNOT_BASE_URL + this.variables.IDNOT_CONNEXION_URL + "?" + query);
|
||||
|
||||
|
||||
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());
|
||||
|
||||
const decodedToken = (await token.json()) as IIdNotToken;
|
||||
console.log("decodedToken", decodedToken);
|
||||
|
||||
|
||||
const decodedIdToken = jwt.decode(decodedToken.id_token) as IdNotJwtPayload;
|
||||
console.log("decodedIdToken", decodedIdToken);
|
||||
|
||||
const decodedIdToken = jwt.decode(decodedToken.id_token) as IdNotJwtPayload;
|
||||
|
||||
|
||||
return decodedIdToken;
|
||||
|
Loading…
x
Reference in New Issue
Block a user