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.
 
 

25 lines
776 B

function getCookie(name) {
var value = `; ${document.cookie}`;
var pairs = value.split("; " + name + "=");
if (pairs.length == 2) {
return pairs.pop().split(";").shift()
};
}
if (document.location.host == 'gitcourse.test.kfcoding.com') {
var token=getCookie('token');
fetch('http://api.kfcoding.com/api/basic/users/current', {
headers: {
'Content-Type': 'application/json',
'Authorization': token
},
method: 'GET',
}).then(response => response.json()).then(data => {
if (data.status !== 200) {
window.location.href = "http://kfcoding.com/user/login?redirect=" + window.location.href;
}
else{
window.env=[`token=${token}`]
}
});
}