Skip to content

Commit

Permalink
Merge pull request #243 from LibreSign/validate-byuuid
Browse files Browse the repository at this point in the history
Validation by route using UUID
  • Loading branch information
vinicios-gomes committed May 19, 2021
2 parents 7371d17 + d4453b2 commit 664569b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ public function resetPassword() {
* @PublicPage
*/
public function validationFile(string $uuid) {
Util::addScript(Application::APP_ID, 'libresign-validation-teste.js');
$this->initialState->provideInitialState('config', json_encode($this->getConfig('url')));

Util::addScript(Application::APP_ID, 'libresign-validation');
$response = new TemplateResponse(Application::APP_ID, 'validation', [], TemplateResponse::RENDER_AS_BASE);

Expand Down
4 changes: 4 additions & 0 deletions src/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const routes = [
path: '/validation',
component: () => import('../views/Validation'),
name: 'validation',
}, {
path: '/validation/:uuid',
component: () => import('../views/Validation'),
name: 'validationFile',
}, {
path: '/sign/:uuid',
component: () => import('../views/DefaultPageError'),
Expand Down
18 changes: 15 additions & 3 deletions src/views/Validation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<h1>{{ title }}</h1>
<h3>{{ legend }}</h3>
<input v-model="uuid" type="text">
<button :class="hasLoading ? 'btn-load primary loading':'btn'" @click.prevent="validateByUUID">
<button :class="hasLoading ? 'btn-load primary loading':'btn'" @click.prevent="validateByUUID(uuid)">
{{ buttonTitle }}
</button>
</form>
Expand Down Expand Up @@ -85,13 +85,25 @@ export default {
hasInfo: false,
hasLoading: false,
document: {},
documentUuid: '',
}
},
watch: {
'$route.params'(toParams, previousParams) {
this.uuid = toParams.uuid
},
},
created() {
setTimeout(() => {
this.validateByUUID(this.uuid)
}, 100)
},
methods: {
async validateByUUID() {
async validateByUUID(uuid) {
this.hasLoading = true
try {
const response = await axios.get(generateUrl(`/apps/libresign/api/0.1/file/validate/uuid/${this.uuid}`))
const response = await axios.get(generateUrl(`/apps/libresign/api/0.1/file/validate/uuid/${uuid}`))
showSuccess(t('libresign', 'This document is valid'))
this.document = response.data
this.hasInfo = true
Expand Down

0 comments on commit 664569b

Please sign in to comment.