feat: checkNoteIdOrAlias in more alias service methods

This should prevent any interaction by a forbidden id

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-02-06 22:09:22 +01:00
parent 6269c7f7bc
commit c891a95588
4 changed files with 17 additions and 17 deletions

View file

@ -157,20 +157,15 @@ export class NotesService {
* @param {string} noteIdOrAlias - the notes id or alias
* @return {Note} the note
* @throws {NotInDBError} there is no note with this id or alias
* @throws {ForbiddenIdError} the requested id or alias is forbidden
*/
async getNoteByIdOrAlias(noteIdOrAlias: string): Promise<Note> {
this.logger.debug(
`Trying to find note '${noteIdOrAlias}'`,
'getNoteByIdOrAlias',
);
try {
this.checkNoteIdOrAlias(noteIdOrAlias);
} catch (e) {
if (e instanceof ForbiddenIdError) {
throw new NotInDBError(e.message);
}
throw e;
}
this.checkNoteIdOrAlias(noteIdOrAlias);
/**
* This query gets the note's aliases, owner, groupPermissions (and the groups), userPermissions (and the users) and tags and