From 4208b46bb39e2caf8691c88e7f5575daf1db71cf Mon Sep 17 00:00:00 2001 From: Martin Araneda Date: Fri, 10 Feb 2023 22:37:00 -0300 Subject: [PATCH] minor changes --- frontend/package.json | 1 + frontend/src/layout/AppTopbar.vue | 9 ++++++--- frontend/yarn.lock | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 21a8063..c4acf7c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -14,6 +14,7 @@ "axios": "^1.3.2", "chart.js": "^4.2.0", "file-saver": "^2.0.5", + "jwt-decode": "^3.1.2", "pinia": "^2.0.28", "primeflex": "^3.3.0", "primeicons": "^6.0.1", diff --git a/frontend/src/layout/AppTopbar.vue b/frontend/src/layout/AppTopbar.vue index 5089658..9e770c7 100644 --- a/frontend/src/layout/AppTopbar.vue +++ b/frontend/src/layout/AppTopbar.vue @@ -4,6 +4,7 @@ import { useLayout } from '@/layout/composables/layout'; import { useRouter } from 'vue-router'; import { useToast } from 'primevue/usetoast'; import axios from 'axios'; +import jwt_decode from 'jwt-decode'; const { onMenuToggle } = useLayout(); @@ -58,15 +59,17 @@ async function onClickPasswordChange() { password: user.value.current_password, new_password: user.value.new_password }; - /* try { - const response = await axios.patch(`http://localhost:3001/user/` + user.value.ID, auth.getTokenHeader()); + var token = localStorage.getItem("token"); + var decoded = jwt_decode(token); + try { + const response = await axios.patch(`http://localhost:3001/user/` + decoded.id, auth.getTokenHeader()); if (response.status !== 204) { console.error(response); } } catch (error) { console.error(error); - } */ + } } diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 29b1520..ef6bd9d 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -1120,6 +1120,11 @@ json-stable-stringify-without-jsonify@^1.0.1: resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== +jwt-decode@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/jwt-decode/-/jwt-decode-3.1.2.tgz#3fb319f3675a2df0c2895c8f5e9fa4b67b04ed59" + integrity sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A== + levn@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade"