Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions nexus-api/src/person/person.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class PersonService {

if (!person) throw new NotFoundException('Pessoa não encontrada.');
if (person.id !== tokenPayload.sub)
throw new ForbiddenException('Você não tem autorização para atualizar.');
throw new ForbiddenException('Você não tem autorização para atualizar essa pessoa.');

await this.personRepository.save(person);
return person;
Expand All @@ -118,7 +118,7 @@ export class PersonService {

if (!person) throw new NotFoundException('Pessoa não encontrada.');
if (person.id !== tokenPayload.sub)
throw new ForbiddenException('Você não tem autorização para atualizar.');
throw new ForbiddenException('Você não tem autorização para deletar essa pessoa.');

await this.personRepository.delete(person.id);
return person;
Expand All @@ -140,7 +140,10 @@ export class PersonService {
.toLowerCase()
.substring(1);
const fileName = `${tokenPayload.sub}.${fileExtension}`;
const fileFullPath = path.resolve(process.cwd(), 'pictures', fileName);
const pictureDir = path.resolve(process.cwd(), 'pictures');
const fileFullPath = path.join(pictureDir, fileName);

await fs.mkdir(pictureDir, { recursive: true });

await fs.writeFile(fileFullPath, file.buffer);

Expand Down