Skip to content

Commit

Permalink
adding some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
psachmann committed Oct 14, 2024
1 parent bf2320f commit 2a65d82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
});
Expand All @@ -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,
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/<externalKlasseId>?schuleId=<externalSchoolDto.externalId>
const externalClassDtoList = payload.ptscListKlasseId
? [new ExternalClassDto({ externalId: payload.ptscListKlasseId, name: '' })]
: [];
.split(',')
.map((externalId) => new ExternalClassDto({ externalId, name: '' }));

const oauthDataDto = new OauthDataDto({
system: input.system,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2a65d82

Please sign in to comment.