add access token

This commit is contained in:
Nguyễn Hải Dũng 2022-12-20 10:49:41 +07:00
parent 11cec7054b
commit d87ed2c096
14 changed files with 45 additions and 9 deletions

View File

@ -1,4 +1,4 @@
import { login } from 'actions/isLogin'; import { login } from '../../actions/isLogin';
import React, { Component } from 'react'; import React, { Component } from 'react';
import "react-datepicker/dist/react-datepicker.css"; import "react-datepicker/dist/react-datepicker.css";
import { HOST } from '../../config/index'; import { HOST } from '../../config/index';

View File

@ -59,6 +59,7 @@ class ImportImage extends Component {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': Store.getState().isLogin.access_token,
// 'Authorization': token // 'Authorization': token
}, },
data: { data: {
@ -129,6 +130,7 @@ class ImportImage extends Component {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': Store.getState().isLogin.access_token,
// 'Authorization': token // 'Authorization': token
}, },
body: JSON.stringify({ 'image_obj_id_list': [img._id] }) body: JSON.stringify({ 'image_obj_id_list': [img._id] })

View File

@ -10,6 +10,7 @@ import { HOST } from '../../config/index';
import swal from 'sweetalert'; import swal from 'sweetalert';
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import Store from '../../store';
const initialDataPost = { const initialDataPost = {
index: 1, index: 1,
@ -76,6 +77,7 @@ export default function LabelImage() {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': Store.getState().isLogin.access_token,
// 'Authorization': token, // 'Authorization': token,
}, },
data: dataDel, data: dataDel,
@ -119,6 +121,7 @@ export default function LabelImage() {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': Store.getState().isLogin.access_token,
// 'Authorization': token // 'Authorization': token
}, },
data: data ? data : dataPost, data: data ? data : dataPost,

View File

@ -10,6 +10,7 @@ import { HOST } from '../../config/index';
import swal from 'sweetalert'; import swal from 'sweetalert';
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import Store from '../../store';
const initialDataPost = { const initialDataPost = {
index: 1, index: 1,
@ -74,6 +75,7 @@ export default function ListItem() {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token, // 'Authorization': token,
'Authorization': Store.getState().isLogin.access_token,
}, },
data: dataDel, data: dataDel,
}) })
@ -117,6 +119,7 @@ export default function ListItem() {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token // 'Authorization': token
'Authorization': Store.getState().isLogin.access_token,
}, },
data: data ? data : dataPost, data: data ? data : dataPost,
}) })

View File

@ -9,6 +9,7 @@ import React, { useEffect, useRef, useState } from 'react';
import { Button, Modal } from 'react-bootstrap'; import { Button, Modal } from 'react-bootstrap';
import swal from 'sweetalert'; import swal from 'sweetalert';
import { HOST } from '../../config/index'; import { HOST } from '../../config/index';
import Store from '../../store';
@ -85,6 +86,8 @@ const ModalEditLabel = (props) => {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token, // 'Authorization': token,
'Authorization': Store.getState().isLogin.access_token,
}, },
data: dataPost, data: dataPost,
}) })
@ -232,6 +235,8 @@ const ModalEditLabel = (props) => {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token // 'Authorization': token
'Authorization': Store.getState().isLogin.access_token,
}, },
body: JSON.stringify(dataUploadImg) body: JSON.stringify(dataUploadImg)
}) })
@ -277,6 +282,8 @@ const ModalEditLabel = (props) => {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': Store.getState().isLogin.access_token,
// 'Authorization': token // 'Authorization': token
}, },
body: JSON.stringify({ body: JSON.stringify({

View File

@ -9,6 +9,7 @@ import React, { useEffect, useRef, useState } from 'react';
import { Button, Modal } from 'react-bootstrap'; import { Button, Modal } from 'react-bootstrap';
import swal from 'sweetalert'; import swal from 'sweetalert';
import { HOST } from '../../config/index'; import { HOST } from '../../config/index';
import Store from '../../store';
@ -84,6 +85,8 @@ const Modaledit = (props) => {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': Store.getState().isLogin.access_token,
// 'Authorization': token, // 'Authorization': token,
}, },
data: dataPost, data: dataPost,
@ -229,6 +232,8 @@ const Modaledit = (props) => {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': Store.getState().isLogin.access_token,
// 'Authorization': token // 'Authorization': token
}, },
body: JSON.stringify(dataUploadImg) body: JSON.stringify(dataUploadImg)
@ -273,7 +278,7 @@ const Modaledit = (props) => {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token 'Authorization': Store.getState().isLogin.access_token,
}, },
body: JSON.stringify({ body: JSON.stringify({
person_obj_id: crrData._id ? crrData._id : "", person_obj_id: crrData._id ? crrData._id : "",

View File

@ -3,6 +3,7 @@ import moment from 'moment';
import 'moment/locale/vi'; import 'moment/locale/vi';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Button, Modal } from 'react-bootstrap'; import { Button, Modal } from 'react-bootstrap';
import Store from '../../store';
import swal from 'sweetalert'; import swal from 'sweetalert';
import { HOST } from '../../config/index'; import { HOST } from '../../config/index';
@ -25,11 +26,11 @@ class ModalEditImg extends Component {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token 'Authorization': Store.getState().isLogin.access_token,
}, },
body: JSON.stringify({ body: JSON.stringify({
"origin_name": this.state.valueImg.origin_name, "origin_name": this.state.valueImg.origin_name,
"obj_id": this.state.valueImg._id "obj_id": this.state.valueImg._id,
}) })
}).then((response) => { }).then((response) => {
return ( return (

View File

@ -5,6 +5,7 @@ import Switch from "react-switch";
import swal from 'sweetalert'; import swal from 'sweetalert';
import $ from 'jquery'; import $ from 'jquery';
import Select from "react-select"; import Select from "react-select";
import Store from '../../store';
import { HOST } from '../../config/index'; import { HOST } from '../../config/index';
class ModalRole extends Component { class ModalRole extends Component {
@ -61,6 +62,7 @@ class ModalRole extends Component {
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token // 'Authorization': token
'Authorization': Store.getState().isLogin.access_token,
}, },
body: JSON.stringify(dataPost) body: JSON.stringify(dataPost)
}).then((response) => { }).then((response) => {
@ -96,7 +98,7 @@ class ModalRole extends Component {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token 'Authorization': Store.getState().isLogin.access_token,
}, },
body: JSON.stringify(dataPost) body: JSON.stringify(dataPost)
}).then((response) => { }).then((response) => {
@ -178,6 +180,8 @@ class ModalRole extends Component {
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token // 'Authorization': token
'Authorization': Store.getState().isLogin.access_token,
}, },
}).then((response) => { }).then((response) => {
return response.json() return response.json()
@ -196,6 +200,8 @@ class ModalRole extends Component {
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token // 'Authorization': token
'Authorization': Store.getState().isLogin.access_token,
}, },
}).then((response) => { }).then((response) => {
return response.json() return response.json()

View File

@ -9,6 +9,7 @@ import LoadingOverlay from 'react-loading-overlay';
import { PulseLoader } from 'react-spinners'; import { PulseLoader } from 'react-spinners';
import swal from 'sweetalert'; import swal from 'sweetalert';
import { HOST } from '../../config/index'; import { HOST } from '../../config/index';
import Store from '../../store';
const { Dragger } = Upload; const { Dragger } = Upload;
@ -40,6 +41,7 @@ const ModalUpload = (props) => {
headers: { headers: {
"X-Requested-With": "XMLHttpRequest", "X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
'Authorization': Store.getState().isLogin.access_token,
} }
}) })
) )

View File

@ -9,6 +9,7 @@ import React, { useEffect, useRef, useState } from 'react';
import { Button, Modal } from 'react-bootstrap'; import { Button, Modal } from 'react-bootstrap';
import swal from 'sweetalert'; import swal from 'sweetalert';
import { HOST } from '../../config/index'; import { HOST } from '../../config/index';
import Store from '../../store';
const { Option } = Select; const { Option } = Select;
@ -85,6 +86,7 @@ const ModalUser = (props) => {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token, // 'Authorization': token,
'Authorization': Store.getState().isLogin.access_token,
}, },
data: dataPost, data: dataPost,
}) })

View File

@ -51,6 +51,7 @@ class Role extends Component {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token // 'Authorization': token
'Authorization': Store.getState().isLogin.access_token,
}, },
}).then((response) => { }).then((response) => {
return response.json() return response.json()
@ -91,6 +92,7 @@ class Role extends Component {
method: 'DELETE', method: 'DELETE',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': Store.getState().isLogin.access_token,
// 'Authorization': token, // 'Authorization': token,
}, },
}).then((response) => { }).then((response) => {

View File

@ -135,7 +135,7 @@ class SearchImage extends Component {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJjbGFzc2lmeS9sb2dpbiJdLCJleHAiOjE2NDE5NzQ5NjV9.2F2PAUKjpfjPJKzgvzgCDtyBuTXDRl86EnJJGdYgWTM' 'Authorization': Store.getState().isLogin.access_token,
}, },
body: JSON.stringify({ body: JSON.stringify({
encodings: this.state.selectedEncoding, encodings: this.state.selectedEncoding,
@ -205,6 +205,7 @@ class SearchImage extends Component {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': Store.getState().isLogin.access_token,
}, },
body: JSON.stringify({ body: JSON.stringify({
image: image_base64 image: image_base64

View File

@ -12,6 +12,7 @@ import swal from 'sweetalert';
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import Switch from "react-switch"; import Switch from "react-switch";
import Select from "react-select"; import Select from "react-select";
import Store from '../../store';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
const initialDataPost = { const initialDataPost = {
@ -86,7 +87,7 @@ export default function User() {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token, 'Authorization': Store.getState().isLogin.access_token,
}, },
}) })
if (result.data.status === 10000) { if (result.data.status === 10000) {
@ -137,7 +138,7 @@ export default function User() {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// 'Authorization': token 'Authorization': Store.getState().isLogin.access_token,
}, },
data: data ? data : dataPost, data: data ? data : dataPost,
}) })

View File

@ -29,6 +29,7 @@ class Header extends Component {
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': Store.getState().isLogin.access_token,
}, },
}) })
.then(response => { .then(response => {