diff --git a/apps/server/src/modules/provisioning/service/tsp-provisioning.service.ts b/apps/server/src/modules/provisioning/service/tsp-provisioning.service.ts index 4fd22c3d5e1..7c5cdd5324a 100644 --- a/apps/server/src/modules/provisioning/service/tsp-provisioning.service.ts +++ b/apps/server/src/modules/provisioning/service/tsp-provisioning.service.ts @@ -14,6 +14,8 @@ import { BadDataLoggableException } from '../loggable'; export class TspProvisioningService { private ENTITY_SOURCE = 'tsp'; // used as source attribute in created users and classes + private TSP_EMAIL_DOMAIN = 'tsp.de'; + constructor( private readonly schoolService: SchoolService, private readonly classService: ClassService, @@ -122,7 +124,7 @@ export class TspProvisioningService { schoolId, firstName: externalUser.firstName, lastName: externalUser.lastName, - email: this.createTspEmail(externalUser.firstName, externalUser.lastName), + email: this.createTspEmail(externalUser.externalId), birthday: externalUser.birthday, externalId: externalUser.externalId, }); @@ -137,9 +139,11 @@ export class TspProvisioningService { const account = await this.accountService.findByUserId(user.id); if (account) { + // Updates account with new systemId and username await account.update(new AccountSave({ userId: user.id, systemId, username: user.email, activated: true })); await this.accountService.save(account); } else { + // Creates new account for user await this.accountService.saveWithValidation( new AccountSave({ userId: user.id, @@ -158,8 +162,8 @@ export class TspProvisioningService { return roleRefs; } - private createTspEmail(firstname: string, lastname: string): string { - const email = `${firstname}.${lastname}@tsp.de`; + private createTspEmail(externalId: string): string { + const email = `${externalId}@${this.TSP_EMAIL_DOMAIN}`; return email.toLowerCase(); } diff --git a/apps/server/src/modules/provisioning/strategy/tsp/tsp.strategy.ts b/apps/server/src/modules/provisioning/strategy/tsp/tsp.strategy.ts index 12740c1401d..8bcc4d2d9a0 100644 --- a/apps/server/src/modules/provisioning/strategy/tsp/tsp.strategy.ts +++ b/apps/server/src/modules/provisioning/strategy/tsp/tsp.strategy.ts @@ -52,9 +52,11 @@ export class TspProvisioningStrategy extends ProvisioningStrategy { externalId: payload.ptscSchuleNummer || '', }); + // TODO: The name is currently missing, should we fetch it from the tsp api? + // Endpoint: /backend_schule_klasse_detail/?schuleId= const externalClassDtoList = payload.ptscListKlasseId - ? [new ExternalClassDto({ externalId: payload.ptscListKlasseId, name: '' })] - : []; + .split(',') + .map((externalId) => new ExternalClassDto({ externalId, name: '' })); const oauthDataDto = new OauthDataDto({ system: input.system, @@ -87,7 +89,7 @@ export class TspProvisioningStrategy extends ProvisioningStrategy { return RoleName.TEACHER; case 'schueler': return RoleName.STUDENT; - case 'administrator': + case 'admin': return RoleName.ADMINISTRATOR; default: return RoleName.USER;