test log for stg
This commit is contained in:
parent
3686edb1ce
commit
5b31f74e33
@ -36,10 +36,14 @@ export default class UserController extends ApiController {
|
|||||||
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");
|
||||||
@ -73,7 +77,9 @@ 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;
|
||||||
@ -117,6 +123,8 @@ 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;
|
||||||
|
|
||||||
|
|
||||||
@ -126,9 +134,11 @@ export default class UserController extends ApiController {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!isSubscribed) {
|
if (!isSubscribed) {
|
||||||
this.httpUnauthorized(response, "User not subscribed");
|
this.httpUnauthorized(response, "User not subscribed");
|
||||||
|
@ -121,14 +121,22 @@ 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;
|
const decodedIdToken = jwt.decode(decodedToken.id_token) as IdNotJwtPayload;
|
||||||
|
console.log("decodedIdToken", decodedIdToken);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return decodedIdToken;
|
return decodedIdToken;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user