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, has_verified_email: true,
is_identity_verified: true, is_identity_verified: true,
is_reward_approved: false, is_reward_approved: false,
is_reward_eligible: false,
}); });
}); });
} }
@ -177,31 +176,19 @@ lbryio.authenticate = function() {
return; return;
} }
let app_id;
return lbry return lbry
.status() .status()
.then(status => { .then(status => {
// first try swapping
app_id = status.installation_id;
return lbryio.call(
"user",
"token_swap",
{ auth_token: "", app_id: app_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( return lbryio.call(
"user", "user",
"new", "new",
{ auth_token: "", language: "en", app_id: app_id }, {
auth_token: "",
language: "en",
app_id: status.installation_id,
},
"post" "post"
); );
}
throw err;
}) })
.then(response => { .then(response => {
if (!response.auth_token) { if (!response.auth_token) {