diff --git a/server.js b/server.js index b05799d..555bd5e 100644 --- a/server.js +++ b/server.js @@ -85,22 +85,22 @@ var upload = multer({ storage: storage }).single('file') app.post('/upload', function(req, res, next) { - console.log('email is' + req.body.email); + console.log('email is ' + req.query.email); - upload(req, res, function(err) { - if (err instanceof multer.MulterError) { - return res.status(500).json(err) - } else if (err) { - return res.status(500).json(err) - } - else { - var FileName = req.file.filename; - callInitFileMover(res); - res.status(200).send(FileName); - } - //return res.status(200).send(req.file) + // upload(req, res, function(err) { + // if (err instanceof multer.MulterError) { + // return res.status(500).json(err) + // } else if (err) { + // return res.status(500).json(err) + // } + // else { + // var FileName = req.file.filename; + // callInitFileMover(res); + // res.status(200).send(FileName); + // } + // //return res.status(200).send(req.file) - }) + // }) }); diff --git a/src/containers/TheContent.js b/src/containers/TheContent.js index 8e79622..0437b82 100644 --- a/src/containers/TheContent.js +++ b/src/containers/TheContent.js @@ -28,11 +28,11 @@ const TheContent = () => { 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://fsbsso.sumasen.net/Shibboleth.sso/Session'); - // if(JSON.stringify(SsoSession) !== JSON.stringify(result.data)) { - // setSsoSession(result.data); - // } + //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://fsbsso.sumasen.net/Shibboleth.sso/Session'); + if(JSON.stringify(SsoSession) !== JSON.stringify(result.data)) { + setSsoSession(result.data); + } } useEffect(() => { @@ -93,47 +93,47 @@ const TheContent = () => { function get_token_from_storage_or_cookie() { //return true; - // const cookies = new Cookies(); - // const shib = cookies.get('_shibsession_64656661756c7468747470733a2f2f66736273736f2e73756d6173656e2e6e65742f73686962626f6c657468') - // if (shib !== undefined) { - // fetchSession().then(() => { - // if (SsoSession !== null) { - // console.log(shib); - // fetchUser().then(() => { - // if(UserId === ''){ - // let id = Math.floor(100000 + Math.random() * 900000) - // setUserId(id); - // } - // const _firstname = UserData.firstname; - // const _lastname = UserData.lastname; - // const _email = UserData.email; - // const _empcode = UserData.employee_code; + const cookies = new Cookies(); + const shib = cookies.get('_shibsession_64656661756c7468747470733a2f2f66736273736f2e73756d6173656e2e6e65742f73686962626f6c657468') + if (shib !== undefined) { + fetchSession().then(() => { + if (SsoSession !== null) { + console.log(shib); + fetchUser().then(() => { + if(UserId === ''){ + let id = Math.floor(100000 + Math.random() * 900000) + setUserId(id); + } + const _firstname = UserData.firstname; + const _lastname = UserData.lastname; + const _email = UserData.email; + const _empcode = UserData.employee_code; - // const json_str = `[ - // { - // "mailadress": "${_email}", - // "name": "${_lastname} ${_firstname}", - // "jsessionid": ${UserId}, - // "_idp_session": "", - // "_opensaml_key": "_shibsession_64656661756c7468747470733a2f2f66736273736f2e73756d6173656e2e6e65742f73686962626f6c657468", - // "_opensaml_value": "${shib}" - // } - // ]`; + const json_str = `[ + { + "mailadress": "${_email}", + "name": "${_lastname} ${_firstname}", + "jsessionid": ${UserId}, + "_idp_session": "", + "_opensaml_key": "_shibsession_64656661756c7468747470733a2f2f66736273736f2e73756d6173656e2e6e65742f73686962626f6c657468", + "_opensaml_value": "${shib}" + } + ]`; - // //const json_str = '[{"jsessonid": "' + UserId + '" , "name": "' + _firstname + ' ' +_lastname+ '", "mailadress":" ' + _email + '", "empcode": "' + _empcode + '"}]'; - // if(_empcode !== null && _empcode !== undefined){ - // if(isCSVPath()){ - // postUserData(json_str); - // } - // } - // return true; - // }); - // } - // }); - // } else { - // return null; - // } + //const json_str = '[{"jsessonid": "' + UserId + '" , "name": "' + _firstname + ' ' +_lastname+ '", "mailadress":" ' + _email + '", "empcode": "' + _empcode + '"}]'; + if(_empcode !== null && _empcode !== undefined){ + if(isCSVPath()){ + postUserData(json_str); + } + } + return true; + }); + } + }); + } else { + return null; + } } @@ -151,7 +151,7 @@ const TheContent = () => { render = { props => get_token_from_storage_or_cookie() !== null ? - ( + ( ) : ( { // then print response status //console.log(res.statusText) if (res.statusText == 'OK') {