diff options
| author | Rafi Zadanly <rafizadanly@gmail.com> | 2022-12-27 17:39:58 +0700 |
|---|---|---|
| committer | Rafi Zadanly <rafizadanly@gmail.com> | 2022-12-27 17:39:58 +0700 |
| commit | eec336f3ae76b7cd27aa5fad8b539ccb103a0455 (patch) | |
| tree | 150784d07aaf3995a044d3d1cfaa19945f669512 | |
| parent | 1e12cbcedbb8eaf52982cef89e35a29b0e555537 (diff) | |
no message
| -rw-r--r-- | src/helpers/apiOdoo.js | 4 | ||||
| -rw-r--r-- | src/pages/my/profile.js | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/helpers/apiOdoo.js b/src/helpers/apiOdoo.js index 22fd1920..4d0adae3 100644 --- a/src/helpers/apiOdoo.js +++ b/src/helpers/apiOdoo.js @@ -1,5 +1,6 @@ import { getCookie, setCookie } from 'cookies-next'; import axios from 'axios'; +import { getAuth } from './auth'; const renewToken = async () => { let token = await axios.get(process.env.SELF_HOST + '/api/token'); @@ -23,6 +24,9 @@ const apiOdoo = async (method, url, data = {}, headers = {}) => { url: process.env.ODOO_HOST + url, headers: {'Authorization': token, ...headers} } + const auth = getAuth(); + + if (auth) axiosParameter.headers['Token'] = auth.token; if (method.toUpperCase() == 'POST') axiosParameter.headers['Content-Type'] = 'application/x-www-form-urlencoded'; if (Object.keys(data).length > 0) axiosParameter.data = new URLSearchParams(Object.entries(data)).toString(); diff --git a/src/pages/my/profile.js b/src/pages/my/profile.js index f1d0a701..be1a67b0 100644 --- a/src/pages/my/profile.js +++ b/src/pages/my/profile.js @@ -20,8 +20,7 @@ export default function MyProfile() { let dataToUpdate = { name: auth.name, phone: auth.phone, - mobile: auth.mobile, - token: auth.token + mobile: auth.mobile }; if (password) dataToUpdate.password = password; let update = await apiOdoo('PUT', `/api/v1/user/${auth.id}`, dataToUpdate); |
