migrate unlink google to pokerogue-api

This commit is contained in:
flx-sta 2024-10-04 10:43:45 -07:00
parent 8ac7ad4221
commit 8fa0d82a6c
2 changed files with 23 additions and 7 deletions

View File

@ -377,14 +377,33 @@ export class PokerogueApi extends Api {
*/
public async unlinkDiscord() {
try {
const response = await this.doPost("/unlink/discord");
const response = await this.doPost("/auth/discord/logout");
if (response.ok) {
return true;
} else {
console.warn(`Unlink failed (${response.status}: ${response.statusText})`);
console.warn(`Discord unlink failed (${response.status}: ${response.statusText})`);
}
} catch (err) {
console.warn("Could not unlink discord!", err);
console.warn("Could not unlink Discord!", err);
}
return false;
}
/**
* Unlink the currently logged in user from Google.
* @returns `true` if unlinking was successful, `false` if not
*/
public async unlinkGoogle() {
try {
const response = await this.doPost("/auth/google/logout");
if (response.ok) {
return true;
} else {
console.warn(`Google Unlink failed (${response.status}: ${response.statusText})`);
}
} catch (err) {
console.warn("Could not unlink Google!", err);
}
return false;

View File

@ -532,10 +532,7 @@ export default class MenuUiHandler extends MessageUiHandler {
window.open(googleUrl, "_self");
return true;
} else {
Utils.apiPost("/auth/google/logout", undefined, undefined, true).then(res => {
if (!res.ok) {
console.error(`Unlink failed (${res.status}: ${res.statusText})`);
}
pokerogueApi.unlinkGoogle().then(_isSuccess => {
updateUserInfo().then(() => this.scene.reset(true, true));
});
return true;