no more token swapping

This commit is contained in:
Alex Grintsvayg 2017-08-24 15:07:16 -04:00
parent 3de3dd2544
commit 7e6c55c605

View file

@ -148,7 +148,6 @@ lbryio.authenticate = function() {
has_verified_email: true,
is_identity_verified: true,
is_reward_approved: false,
is_reward_eligible: false,
});
});
}
@ -177,32 +176,20 @@ lbryio.authenticate = function() {
return;
}
let app_id;
return lbry
.status()
.then(status => {
// first try swapping
app_id = status.installation_id;
return lbryio.call(
"user",
"token_swap",
{ auth_token: "", app_id: app_id },
"new",
{
auth_token: "",
language: "en",
app_id: status.installation_id,
},
"post"
);
})
.catch(err => {
if (err.xhr.status == 403) {
// cannot swap. either app_id doesn't exist, or app_id already swapped. pretend its the former and create a new user. if we get another error, then its the latter
return lbryio.call(
"user",
"new",
{ auth_token: "", language: "en", app_id: app_id },
"post"
);
}
throw err;
})
.then(response => {
if (!response.auth_token) {
throw new Error(__("auth_token is missing from response"));