Skip to content

Commit

Permalink
feat: ouvrir avenir pro
Browse files Browse the repository at this point in the history
  • Loading branch information
Mzem committed Dec 3, 2024
1 parent 07a6f4a commit 2cc65c6
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Module } from '@nestjs/common'
import { ConfigModule } from '@nestjs/config'
import { TerminusModule } from '@nestjs/terminus'
import { AccountModule } from './account/account.module'
import { AppController } from './app.controller'
import configuration from './config/configuration'
import { ConseilDepartementalConseillerModule } from './idp/conseildepartemental-conseiller/conseildepartemental-conseiller.module'
import { FrancetravailConseillerModule } from './idp/francetravail-conseiller/francetravail-conseiller.module'
import { FrancetravailJeuneModule } from './idp/francetravail-jeune/francetravail-jeune.module'
import { MiloConseillerModule } from './idp/milo-conseiller/milo-conseiller.module'
import { MiloJeuneModule } from './idp/milo-jeune/milo-jeune.module'
import { configureLoggerModule } from './utils/monitoring/logger.module'
import { TerminusModule } from '@nestjs/terminus'
import { AccountModule } from './account/account.module'
import { ConseilDepartementalConseillerModule } from './idp/conseildepartemental-conseiller/conseildepartemental-conseiller.module'

@Module({
imports: [
Expand Down
3 changes: 2 additions & 1 deletion src/domain/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export namespace User {
POLE_EMPLOI_BRSA = 'POLE_EMPLOI_BRSA',
POLE_EMPLOI_AIJ = 'POLE_EMPLOI_AIJ',
FRANCE_TRAVAIL = 'FRANCE_TRAVAIL',
CONSEIL_DEPT = 'CONSEIL_DEPT'
CONSEIL_DEPT = 'CONSEIL_DEPT',
AVENIR_PRO = 'AVENIR_PRO'
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Injectable } from '@nestjs/common'
import { ConfigService } from '@nestjs/config'
import { PassEmploiAPIClient } from '../../api/pass-emploi-api.client'
import { User } from '../../domain/user'
import { OidcService } from '../../oidc-provider/oidc.service'
import { TokenService } from '../../token/token.service'
import { IdpService } from '../service/idp.service'

@Injectable()
export class FrancetravailConseillerAvenirProService extends IdpService {
constructor(
configService: ConfigService,
oidcService: OidcService,
tokenService: TokenService,
passemploiapi: PassEmploiAPIClient
) {
super(
'FrancetravailConseillerAvenirProService',
User.Type.CONSEILLER,
User.Structure.AVENIR_PRO,
configService,
oidcService,
tokenService,
passemploiapi
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { FrancetravailConseillerAIJService } from './francetravail-conseiller-ai
import { FrancetravailConseillerBRSAService } from './francetravail-conseiller-brsa.service'
import { FrancetravailConseillerCEJService } from './francetravail-conseiller-cej.service'
import { User } from '../../domain/user'
import { FrancetravailConseillerAvenirProService } from './francetravail-conseiller-avenirpro.service'

@Controller()
export class FrancetravailConseillerController {
Expand All @@ -24,7 +25,8 @@ export class FrancetravailConseillerController {
constructor(
private readonly francetravailConseillerCEJService: FrancetravailConseillerCEJService,
private readonly francetravailConseillerAIJService: FrancetravailConseillerAIJService,
private readonly francetravailConseillerBRSAService: FrancetravailConseillerBRSAService
private readonly francetravailConseillerBRSAService: FrancetravailConseillerBRSAService,
private readonly francetravailConseillerAvenirProService: FrancetravailConseillerAvenirProService
) {
this.logger = new Logger('FrancetravailConseillerController')
}
Expand All @@ -40,6 +42,14 @@ export class FrancetravailConseillerController {
let structure: User.Structure

switch (ftQueryParams.type) {
case 'avenirpro':
structure = User.Structure.AVENIR_PRO
authorizationUrlResult =
this.francetravailConseillerAvenirProService.getAuthorizationUrl(
interactionId,
ftQueryParams.type
)
break
case 'aij':
structure = User.Structure.POLE_EMPLOI_AIJ
authorizationUrlResult =
Expand Down Expand Up @@ -97,6 +107,13 @@ export class FrancetravailConseillerController {
response
)
break
case 'avenirpro':
structure = User.Structure.AVENIR_PRO
result = await this.francetravailConseillerAvenirProService.callback(
request,
response
)
break
case 'brsa':
structure = User.Structure.POLE_EMPLOI_BRSA
result = await this.francetravailConseillerBRSAService.callback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import { FrancetravailConseillerAIJService } from './francetravail-conseiller-ai
import { FrancetravailConseillerBRSAService } from './francetravail-conseiller-brsa.service'
import { FrancetravailConseillerCEJService } from './francetravail-conseiller-cej.service'
import { FrancetravailConseillerController } from './francetravail-conseiller.controller'
import { FrancetravailConseillerAvenirProService } from './francetravail-conseiller-avenirpro.service'

@Module({
imports: [ConfigModule, OidcModule, TokenModule, APIModule],
providers: [
FrancetravailConseillerCEJService,
FrancetravailConseillerAIJService,
FrancetravailConseillerBRSAService
FrancetravailConseillerBRSAService,
FrancetravailConseillerAvenirProService
],
exports: [],
controllers: [FrancetravailConseillerController]
Expand Down
2 changes: 2 additions & 0 deletions src/idp/service/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function getIdpConfigIdentifier(
case User.Structure.POLE_EMPLOI_BRSA:
case User.Structure.POLE_EMPLOI_AIJ:
case User.Structure.CONSEIL_DEPT:
case User.Structure.AVENIR_PRO:
return IdpConfigIdentifier.FT_BENEFICIAIRE
}
case User.Type.CONSEILLER:
Expand All @@ -61,6 +62,7 @@ function getIdpConfigIdentifier(
case User.Structure.POLE_EMPLOI_CEJ:
case User.Structure.POLE_EMPLOI_BRSA:
case User.Structure.POLE_EMPLOI_AIJ:
case User.Structure.AVENIR_PRO:
return IdpConfigIdentifier.FT_CONSEILLER
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/oidc-provider/oidc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ export class OidcService {
return `/francetravail-conseiller/connect/${interaction.uid}?type=brsa`
case 'pe-aij-conseiller':
return `/francetravail-conseiller/connect/${interaction.uid}?type=aij`
case 'avenirpro-conseiller':
return `/francetravail-conseiller/connect/${interaction.uid}?type=avenirpro`
case 'conseildepartemental-conseiller':
return `/conseildepartemental-conseiller/connect/${interaction.uid}`
default:
Expand Down

0 comments on commit 2cc65c6

Please sign in to comment.