-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPSH-1288 #774
base: main
Are you sure you want to change the base?
Conversation
if (permissions) { | ||
if (error) { | ||
this.logger.error( | ||
`Admin ${permissions.personFields.familienname} (${permissions.personFields.id}) hat versucht eine neue Klasse ${organisation.name} (${schoolName}) anzulegen. Fehler: ${error.message}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ist familienname richtig? ich würde einfach den username nehmen
const permissionsMock: PersonPermissions = createMock<PersonPermissions>({ | ||
get personFields(): Person<true> { | ||
return createMock<Person<true>>({ | ||
familienname: 'current-user', | ||
}); | ||
}, | ||
getPersonenkontextewithRoles: (): Promise<PersonenkontextRolleFields[]> => | ||
Promise.resolve([ | ||
{ | ||
organisationsId: '', | ||
rolle: { systemrechte: [], serviceProviderIds: [] }, | ||
}, | ||
]), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leeres Permissions-Objekt sollte an dieser Stelle ausreichend sein.
const permissionsMock: PersonPermissions = createMock<PersonPermissions>({ | ||
get personFields(): Person<true> { | ||
return createMock<Person<true>>({ | ||
familienname: 'current-user', | ||
}); | ||
}, | ||
getPersonenkontextewithRoles: (): Promise<PersonenkontextRolleFields[]> => | ||
Promise.resolve([ | ||
{ | ||
organisationsId: '', | ||
rolle: { systemrechte: [], serviceProviderIds: [] }, | ||
}, | ||
]), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Siehe oben
const permissionsMock: PersonPermissions = createMock<PersonPermissions>({ | ||
get personFields(): Person<true> { | ||
return createMock<Person<true>>({ | ||
familienname: 'current-user', | ||
}); | ||
}, | ||
getPersonenkontextewithRoles: (): Promise<PersonenkontextRolleFields[]> => | ||
Promise.resolve([ | ||
{ | ||
organisationsId: '', | ||
rolle: { systemrechte: [], serviceProviderIds: [] }, | ||
}, | ||
]), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Siehe oben
const permissionsMock: DeepMocked<PersonPermissions> = createMock<PersonPermissions>({ | ||
get personFields(): Person<true> { | ||
return createMock<Person<true>>({ | ||
id: 'test-id', | ||
keycloakUserId: 'test-keycloak', | ||
vorname: 'test-vorname', | ||
familienname: 'test-familienname', | ||
rufname: 'test-rufname', | ||
username: 'test-username', | ||
geschlecht: Geschlecht.M, | ||
geburtsdatum: faker.date.past(), | ||
updatedAt: faker.date.recent(), | ||
}); | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Permissions-Objekt kann hier auch ohne die Spezifizierung für den Test gemocked werden
const permissionsMock: DeepMocked<PersonPermissions> = createMock<PersonPermissions>({ | ||
get personFields(): Person<true> { | ||
return createMock<Person<true>>({ | ||
id: 'test-id', | ||
keycloakUserId: 'test-keycloak', | ||
vorname: 'test-vorname', | ||
familienname: 'test-familienname', | ||
rufname: 'test-rufname', | ||
username: 'test-username', | ||
geschlecht: Geschlecht.M, | ||
geburtsdatum: faker.date.past(), | ||
updatedAt: faker.date.recent(), | ||
}); | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Siehe oben. Überflüssige Importe können dann entfernt werden.
const permissionsMock: PersonPermissions = createMock<PersonPermissions>({ | ||
get personFields(): Person<true> { | ||
return createMock<Person<true>>({ | ||
id: 'test-id', | ||
keycloakUserId: 'test-keycloak', | ||
vorname: 'test-vorname', | ||
familienname: 'test-familienname', | ||
rufname: 'test-rufname', | ||
username: 'test-username', | ||
geschlecht: Geschlecht.M, | ||
geburtsdatum: faker.date.past(), | ||
updatedAt: faker.date.recent(), | ||
}); | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Siehe oben.
@@ -423,13 +428,24 @@ export class OrganisationRepository { | |||
await this.em.removeAndFlush(organisationEntity); | |||
this.eventService.publish(new KlasseDeletedEvent(organisationEntity.id)); | |||
|
|||
let schoolName: string = 'SCHOOL_NOT_FOUND'; | |||
if (permissions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Siehe oben
permissionsMock = createMock<PersonPermissions>({ | ||
get personFields(): Person<true> { | ||
return createMock<Person<true>>({ | ||
id: 'test-id', | ||
keycloakUserId: 'test-keycloak', | ||
vorname: 'test-vorname', | ||
familienname: 'test-familienname', | ||
rufname: 'test-rufname', | ||
username: 'test-username', | ||
geschlecht: Geschlecht.M, | ||
geburtsdatum: faker.date.past(), | ||
updatedAt: faker.date.recent(), | ||
}); | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Siehe oben
rolle: { systemrechte: [], serviceProviderIds: [] }, | ||
}, | ||
]), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Siehe oben
|
||
private async getOrganisationNameForCurrentUser(permissions: PersonPermissions): Promise<string> { | ||
const personenkontextRolleFields: PersonenkontextRolleFields[] = | ||
await permissions?.getPersonenkontextewithRoles(); | ||
const organisationIdUser: string | undefined = personenkontextRolleFields.at(0)?.organisationsId; | ||
if (organisationIdUser) { | ||
const organisationUser: Option<Organisation<true>> = | ||
await this.organisationRepository.findById(organisationIdUser); | ||
if (organisationUser) if (organisationUser.name) return organisationUser.name; | ||
} | ||
this.logger.error(`No Organisation id found for given Person id: ${permissions.personFields.id}`); | ||
return 'ORGANISATION_NOT_FOUND'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ein Benutzer kann mehrere Organisationen und Rollen haben, bzw. eine Person kann mehrere Personenkontexte haben. Ich glaube der Mehrwert ist hier nicht gegeben, sich den ersten Index des Arrays für die Rollen anzuschauen.
if (!orgResult.ok) { | ||
this.logger.info( | ||
`Admin ${permissions.personFields.username} (${permissions.personFields.id}) hat versucht eine neue Rolle ${params.name} anzulegen. Fehler: ${orgResult.error.message}`, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hier logger.error verwenden. Am Besten nochmal überall prüfen.
Description
Links to Tickets or other pull requests
https://ticketsystem.dbildungscloud.de/browse/SPSH-1288
Changes
Datasecurity
Deployment
New Repos, NPM pakages or vendor scripts
Approval for review