Merge branch 'dev' into staging
This commit is contained in:
commit
7910fa3d6b
@ -36,10 +36,14 @@ export default class UserController extends ApiController {
|
||||
protected async getUserInfosFromIdnot(req: Request, response: Response) {
|
||||
try {
|
||||
const code = req.params["code"];
|
||||
console.log("code", code);
|
||||
|
||||
|
||||
if (!code) throw new Error("code is required");
|
||||
|
||||
const idNotToken = await this.idNotService.getIdNotToken(code);
|
||||
console.log("idNotToken", idNotToken);
|
||||
|
||||
|
||||
if (!idNotToken) {
|
||||
this.httpValidationError(response, "IdNot token undefined");
|
||||
@ -74,6 +78,8 @@ 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);
|
||||
|
||||
|
||||
if (!subscriptions || subscriptions.length === 0 || subscriptions[0]?.status === ESubscriptionStatus.INACTIVE) {
|
||||
isSubscribed = false;
|
||||
@ -117,6 +123,8 @@ 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);
|
||||
|
||||
if(!payload) return;
|
||||
|
||||
|
||||
@ -126,9 +134,12 @@ export default class UserController extends ApiController {
|
||||
if(!manageSubscriptionRules[0]) return;
|
||||
|
||||
payload.rules = manageSubscriptionRules[0].rules!.map((rule) => rule.name) || [];
|
||||
console.log("payload with subscription rules", payload);
|
||||
|
||||
isSubscribed = true;
|
||||
}
|
||||
|
||||
|
||||
if (!isSubscribed) {
|
||||
this.httpUnauthorized(response, "User not subscribed");
|
||||
return;
|
||||
|
@ -121,14 +121,22 @@ 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);
|
||||
|
||||
|
||||
|
||||
return decodedIdToken;
|
||||
|
Loading…
x
Reference in New Issue
Block a user