diff --git a/src/containers/TheContent.js b/src/containers/TheContent.js
index 72fe68a..0e66afd 100644
--- a/src/containers/TheContent.js
+++ b/src/containers/TheContent.js
@@ -1,144 +1,144 @@
-import React, { Suspense, useState, useEffect } from 'react'
-import axios from 'axios';
+import React, { Suspense, useState, useEffect } from "react";
+import axios from "axios";
//import Cookies from 'js-cookie';
-import Cookies from 'universal-cookie';
-import {
- Redirect,
- Route,
- useLocation,
- Switch
-} from 'react-router-dom'
-import { CContainer, CFade } from '@coreui/react'
+import Cookies from "universal-cookie";
+import { Redirect, Route, useLocation, Switch } from "react-router-dom";
+import { CContainer, CFade } from "@coreui/react";
// routes config
-import routes from '../routes'
-import Sso from 'src/views/sso';
+import routes from "../routes";
+import Sso from "src/views/sso";
-const loading = ( <
- div className = "pt-3 text-center" >
-
-
-)
+const loading = (
+
+);
const TheContent = () => {
+ const [SsoSession, setSsoSession] = useState("");
+ const [UserData, setUserData] = useState("");
+ const [UserId, setUserId] = useState("");
+ const [isDataFetched, setIsDataFetched] = useState(false);
+ const [isPosted, setPosted] = useState(false);
+ const [GotUserId, setGotUserId] = useState(false);
- const [SsoSession, setSsoSession] = useState('');
- const [UserData, setUserData] = useState('');
- const [UserId, setUserId] = useState('');
- const [isDataFetched, setIsDataFetched] = useState(false);
- const [isPosted, setPosted] = useState(false);
- const [GotUserId, setGotUserId] = useState(false);
-
- async function fetchSession() {
-
- //setSsoSession('{ "expiration": 468, "client_address": "111.223.144.163", "protocol": "urn:oasis:names:tc:SAML:2.0:protocol", "identity_provider": "https://sso.ts.bizside.biz/idp/shibboleth", "authn_instant": "2021-09-03T08:26:41.248Z", "authncontext_class": "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport", "attributes": [ { "name": "mail", "values": [ "akira.miyata@mobilous.com" ] } ] }')
- const result = await axios('https://fbssso.bizside.biz/Shibboleth.sso/Session');
- if(JSON.stringify(SsoSession) !== JSON.stringify(result.data)) {
- //console.log(result.data);
- setSsoSession(result.data);
- }
+ async function fetchSession() {
+ //setSsoSession('{ "expiration": 468, "client_address": "111.223.144.163", "protocol": "urn:oasis:names:tc:SAML:2.0:protocol", "identity_provider": "https://sso.ts.bizside.biz/idp/shibboleth", "authn_instant": "2021-09-03T08:26:41.248Z", "authncontext_class": "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport", "attributes": [ { "name": "mail", "values": [ "akira.miyata@mobilous.com" ] } ] }')
+ const result = await axios(
+ "https://fbssso.bizside.biz/Shibboleth.sso/Session"
+ );
+ if (JSON.stringify(SsoSession) !== JSON.stringify(result.data)) {
+ //console.log(result.data);
+ setSsoSession(result.data);
}
+ }
- useEffect(() => {
- fetchSession()
- get_token_from_storage_or_cookie();
- }, []);
+ useEffect(() => {
+ fetchSession();
+ get_token_from_storage_or_cookie();
+ }, []);
- async function postUserData(data) {
+ async function postUserData(data) {
+ setPosted(true);
- setPosted(true);
+ let axiosConfig = {
+ headers: {
+ "Content-Type": "application/json;charset=UTF-8",
+ "Access-Control-Allow-Origin": "*",
+ },
+ };
- let axiosConfig = {
- headers: {
- 'Content-Type': 'application/json;charset=UTF-8',
- "Access-Control-Allow-Origin": "*",
- }
- };
-
- const result = await axios.post('https://fbssso.bizside.biz/csv', data, axiosConfig)
+ const result = await axios
+ .post("https://fbssso.bizside.biz/csv", data, axiosConfig)
.catch((err) => {
console.log("AXIOS ERROR: ", err);
setPosted(false);
});
- console.log("--- res ----", result);
+ console.log("--- res ----", result);
- if(result === "OK"){
-
- }else{
- console.log("res id ", result.data.id);
- if(data.jsessionid !== result.data.id){
- setUserId(result.data.id);
- setGotUserId(true);
- }
+ if (result === "OK") {
+ } else {
+ console.log("res id ", result.data.id);
+ if (data.jsessionid !== result.data.id) {
+ setUserId(result.data.id);
+ setGotUserId(true);
}
-
- console.log("user data posted");
}
- async function fetchUser() {
- if(SsoSession.attributes == null || SsoSession.attributes[0] === undefined) {
- return false;
- }
- const user_email = SsoSession.attributes[0].values[0]
- //console.log(user_email);
- const company_code = "FBS";
- const key = "api"
- const pwd = "c558a56c63c44f65956adde8863ecc3558f3e55a465d4338bb2e7d2692866fd8";
+ console.log("user data posted");
+ }
- const result = await axios.get('https://fbssso.bizside.biz/users?email=' + user_email, {
+ async function fetchUser() {
+ if (
+ SsoSession.attributes == null ||
+ SsoSession.attributes[0] === undefined
+ ) {
+ return false;
+ }
+ const user_email = SsoSession.attributes[0].values[0];
+ //console.log(user_email);
+ const company_code = "FBS";
+ const key = "api";
+ const pwd =
+ "ae4d70740e7549bda4c118d66e845e450da1af7e918e440eaac16497a9f75292";
+
+ const result = await axios
+ .get("https://fbssso.bizside.biz/users?email=" + user_email, {
auth: {
username: key,
- password: pwd
- }
- }).catch((err) => {
+ password: pwd,
+ },
+ })
+ .catch((err) => {
console.log(err);
return false;
});
- //console.log(result.data);
- if(JSON.stringify(UserData) !== JSON.stringify(result.data[0])) {
- setUserData(result.data[0]);
- }
+ //console.log(result.data);
+ if (JSON.stringify(UserData) !== JSON.stringify(result.data[0])) {
+ setUserData(result.data[0]);
+ }
+ return true;
+ }
+
+ function isCSVPath() {
+ const url = window.location.href;
+ if (url.includes("dashboard")) {
return true;
+ } else {
+ return false;
}
+ }
- function isCSVPath(){
- const url =window.location.href;
- if(url.includes('dashboard')) {
- return true;
- }
- else {
- return false;
- }
- }
+ function getCookie(name) {
+ const value = `; ${document.cookie}`;
+ const parts = value.split(`; ${name}=`);
+ if (parts.length === 2) return parts.pop().split(";").shift();
+ }
- function getCookie(name) {
- const value = `; ${document.cookie}`;
- const parts = value.split(`; ${name}=`);
- if (parts.length === 2) return parts.pop().split(';').shift();
- }
+ function get_token_from_storage_or_cookie() {
+ //const cookies = new Cookies();
+ //console.log(cookies.getAll());
+ const shib = getCookie(
+ "_shibsession_64656661756c7468747470733a2f2f66627373736f2e62697a736964652e62697a2f73686962626f6c657468"
+ );
+ console.log(shib);
+ if (shib !== undefined) {
+ fetchSession().then(() => {
+ if (SsoSession !== null) {
+ fetchUser().then(() => {
+ if (UserId === "") {
+ let id = Math.floor(100000 + Math.random() * 900000);
+ setUserId(id);
+ }
+ setIsDataFetched(true);
+ const _firstname = UserData.firstname;
+ const _lastname = UserData.lastname;
+ const _email = UserData.email;
+ const _empcode = UserData.employee_code;
- function get_token_from_storage_or_cookie() {
- //const cookies = new Cookies();
- //console.log(cookies.getAll());
- const shib = getCookie('_shibsession_64656661756c7468747470733a2f2f66627373736f2e62697a736964652e62697a2f73686962626f6c657468')
- console.log(shib);
- if (shib !== undefined) {
- fetchSession().then(() => {
- if (SsoSession !== null) {
- fetchUser().then(() => {
- if(UserId === ''){
- let id = Math.floor(100000 + Math.random() * 900000)
- setUserId(id);
- }
- setIsDataFetched(true);
-
- const _firstname = UserData.firstname;
- const _lastname = UserData.lastname;
- const _email = UserData.email;
- const _empcode = UserData.employee_code;
-
- const json_str = `[
+ const json_str = `[
{
"mailadress": "${_email}",
"name": "${_lastname} ${_firstname}",
@@ -149,57 +149,61 @@ const TheContent = () => {
}
]`;
-
- //const json_str = '[{"jsessonid": "' + UserId + '" , "name": "' + _firstname + ' ' +_lastname+ '", "mailadress":" ' + _email + '", "empcode": "' + _empcode + '"}]';
- if(_empcode !== null && _empcode !== undefined){
- if(isCSVPath()){
- if(isPosted == false){
- postUserData(json_str);
- }
- }
- }
- return true;
- });
+ //const json_str = '[{"jsessonid": "' + UserId + '" , "name": "' + _firstname + ' ' +_lastname+ '", "mailadress":" ' + _email + '", "empcode": "' + _empcode + '"}]';
+ if (_empcode !== null && _empcode !== undefined) {
+ if (isCSVPath()) {
+ if (isPosted == false) {
+ postUserData(json_str);
}
- });
- } else {
- setIsDataFetched(true);
- return null;
+ }
+ }
+ return true;
+ });
}
-
+ });
+ } else {
+ setIsDataFetched(true);
+ return null;
}
+ }
- return (
-
-
-
-
- {routes.map((route, idx) => {
- return route.component && (
+ return (
+
+
+
+
+ {routes.map((route, idx) => {
+ return (
+ route.component && (
- isDataFetched ?
- get_token_from_storage_or_cookie() !== null ? (
-
- ) : (
-
- )
- :
- null
+ isDataFetched ? (
+ get_token_from_storage_or_cookie() !== null ? (
+
+ ) : (
+
+ )
+ ) : null
}
/>
- );
- })}
-
-
-
-
-
- );
-}
+ )
+ );
+ })}
+
+
+
+
+
+ );
+};
-export default React.memo(TheContent)
+export default React.memo(TheContent);