Merge branch 'dev' into staging
This commit is contained in:
commit
fcb5d138dd
@ -35,15 +35,11 @@ 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");
|
||||||
@ -77,9 +73,7 @@ export default class UserController extends ApiController {
|
|||||||
}
|
}
|
||||||
let isSubscribed = false;
|
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 } });
|
||||||
console.log("subscriptions", subscriptions);
|
|
||||||
|
|
||||||
|
|
||||||
if (!subscriptions || subscriptions.length === 0 || subscriptions[0]?.status === ESubscriptionStatus.INACTIVE) {
|
if (!subscriptions || subscriptions.length === 0 || subscriptions[0]?.status === ESubscriptionStatus.INACTIVE) {
|
||||||
isSubscribed = false;
|
isSubscribed = false;
|
||||||
@ -122,24 +116,16 @@ 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"){
|
||||||
const manageSubscriptionRulesEntity = await this.rulesGroupsService.get({ where: { name: "Gestion de l'abonnement" }, include: { rules: true } });
|
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" });
|
||||||
|
|
||||||
const manageSubscriptionRules = RulesGroup.hydrateArray<RulesGroup>(manageSubscriptionRulesEntity, { strategy: "excludeAll" });
|
|
||||||
console.log("manageSubscriptionRules", manageSubscriptionRules);
|
|
||||||
|
|
||||||
if(!manageSubscriptionRules[0]) return;
|
if(!manageSubscriptionRules[0]) return;
|
||||||
|
|
||||||
payload.rules = manageSubscriptionRules[0].rules!.map((rule) => rule.name) || [];
|
payload.rules = manageSubscriptionRules[0].rules!.map((rule) => rule.name) || [];
|
||||||
console.log("payload with subscription rules", payload);
|
|
||||||
|
|
||||||
isSubscribed = true;
|
isSubscribed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ 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.DATABASE_NAME);
|
||||||
|
|
||||||
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";
|
||||||
|
@ -121,22 +121,15 @@ export default class IdNotService extends BaseService {
|
|||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
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", 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;
|
return decodedIdToken;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user