Skip to content

Commit

Permalink
fix: prevent success when signature file dont exists
Browse files Browse the repository at this point in the history
Signed-off-by: Samuelson Brito <samuelsonma@gmail.com>
  • Loading branch information
samuelsonbrito authored and backportbot-libresign[bot] committed Feb 12, 2025
1 parent da44bff commit 1f32ff2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
10 changes: 8 additions & 2 deletions lib/Service/FolderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,22 @@ public function getFileById(?int $nodeId = null): File {
foreach ($mountsContainingFile as $fileInfo) {
$this->root->getByIdInPath($nodeId, $fileInfo->getMountPoint());
}
/** @var File[] */
$file = $this->root->getById($nodeId);
if ($file) {
/** @var File */
if (!$file[0]->fopen('r')) {
throw new NotFoundException('Invalid node');
}
return $file[0];
}

$folder = $this->root->getUserFolder($this->getUserId());
/** @var File[] */
$file = $folder->getById($nodeId);
if ($file) {
/** @var File */
if (!$file[0]->fopen('r')) {
throw new NotFoundException('Invalid node');
}
return current($file);
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/Components/PreviewSignature/PreviewSignature.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ export default {
.then(response => {
const buffer = Buffer.from(response.data, 'binary').toString('base64')
this.imageData = 'data:application/pdf;base64,' + buffer
this.onImageLoad()
this.onImageLoad(true)
})
.catch(() => this.onImageLoad(false))
},
onImageLoad() {
onImageLoad(status) {
this.loading = false
this.isLoaded = true
this.$emit('loaded')
this.$emit('loaded', status)
},
},
}
Expand Down
8 changes: 5 additions & 3 deletions src/views/Account/partials/Signature.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ export default {
data: () => ({
isEditing: false,
isSignatureLoaded: false,
signatureExists: true,
}),
computed: {
hasSignature() {
return this.signatureElementsStore.hasSignatureOfType(this.type)
return this.signatureElementsStore.hasSignatureOfType(this.type) && this.signatureExists
},
imgSrc() {
if (this.signatureElementsStore.signs[this.type]?.value?.startsWith('data:')) {
Expand All @@ -87,8 +88,9 @@ export default {
},
},
methods: {
signatureLoaded() {
this.isSignatureLoaded = true
signatureLoaded(success) {
this.isSignatureLoaded = success
this.signatureExists = success
},
edit() {
this.isEditing = true
Expand Down

0 comments on commit 1f32ff2

Please sign in to comment.