added user api

This commit is contained in:
2021-08-19 15:35:42 +05:30
parent e778c67b0b
commit 12c9fda91e
19 changed files with 69 additions and 69 deletions

View File

@ -33,11 +33,13 @@ const TheContent = () => {
// You can await here
const result = await axios('https://fsbsso.sumasen.net/Shibboleth.sso/Session');
setSsoSession(result.data);
if(JSON.stringify(SsoSession) !== JSON.stringify(result.data)) {
setSsoSession(result.data);
}
}
async function fetchUser() {
console.log(SsoSession.attributes[0].values[0])
console.log(SsoSession)
const user_email = SsoSession.attributes[0].values[0]
console.log(user_email);
const company_code = "FBS";
@ -45,31 +47,25 @@ const TheContent = () => {
const pwd = "c558a56c63c44f65956adde8863ecc3558f3e55a465d4338bb2e7d2692866fd8";
console.log("making request");
// You can await here
// const result = await axios.get('https://api.ts.bizside.biz/api/v7/' + company_code + '/users?email=' + user_email, {
// auth: {
// username: key,
// password: pwd
// }
// });
const result = await axios.get('https://fsbsso.sumasen.net/users?email=akira.miyata@mobilous.com', {
auth: {
username: key,
password: pwd
}
}).catch((err) => {
console.log(err);
return false;
});
console.log(result.data);
if(UserData !== result.data) {
console.log("same result");
setUserData(result.data);
if(JSON.stringify(UserData) !== JSON.stringify(sdata)) {
setUserData(result.data[0]);
}
return true;
}
function get_token_from_storage_or_cookie() {
console.log("calling ..");
//localStorage.setItem('state', 'off');
// const data = '{ "expiration": 479, "client_address": "123.231.121.140", "protocol": "urn:oasis:names:tc:SAML:2.0:protocol", "identity_provider": "https://sso.ts.bizside.biz/idp/shibboleth", "authn_instant": "2021-08-16T11:29:41.254Z", "authncontext_class": "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport", "attributes": [ { "name": "mail", "values": [ "akira.miyata@mobilous.com" ] } ] }'
@ -80,27 +76,23 @@ const TheContent = () => {
// //console.log(jdata.attributes[0].values[0]);
//return true;
// const cookies = new Cookies();
// const shib = cookies.get('_shibsession_64656661756c7468747470733a2f2f66736273736f2e73756d6173656e2e6e65742f73686962626f6c657468')
// if (shib !== undefined) {
// fetchSession().then(() => {
// if (SsoSession !== null) {
// fetchUser().then(() => {
// console.log('requesting user data');
// console.log(UserData);
// return true;
// });
// }
// });
// } else {
// return null;
// }
const cookies = new Cookies();
const shib = cookies.get('_shibsession_64656661756c7468747470733a2f2f66736273736f2e73756d6173656e2e6e65742f73686962626f6c657468')
if (shib !== undefined) {
fetchSession().then(() => {
if (SsoSession !== null) {
fetchUser().then(() => {
const _firstname = UserData.firstname;
console.log(UserData);
console.log(_firstname);
return true;
});
}
});
} else {
return null;
}
fetchUser().then(() => {
console.log('requesting user data');
console.log(UserData);
return true;
});
}
return (