You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

40 lines
1.1 KiB

const http_build_query = (obj) => {
let str = ""
for (const key in obj) {
const value = obj[key];
str += `${key}=${value}&`;
}
return str;
}
const genUrl = (urlToReturnTo) => {
const params = {
'openid.ns' : 'http://specs.openid.net/auth/2.0',
'openid.mode' : 'checkid_setup',
'openid.return_to' : urlToReturnTo,
'openid.realm' : 'http://localhost:8080',
'openid.identity' : 'http://specs.openid.net/auth/2.0/identifier_select',
'openid.claimed_id' : 'http://specs.openid.net/auth/2.0/identifier_select',
};
const url = `${STEAM_LOGIN}?${http_build_query(params)}`
return url;
};
const search = location.search.substring(1);
const urlObj = JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}')
const getUserId = (response) =>
{
const str = response["openid.claimed_id"];
const res = decodeURIComponent(str)
const propsArr = res.split("\/");
console.log(propsArr);
return propsArr[propsArr.length-1];
}
const userId = getUserId(urlObj)