Fix Account Deletion
This commit is contained in:
parent
755af71912
commit
33e66635c3
2 changed files with 16 additions and 2 deletions
|
|
@ -55,7 +55,7 @@
|
||||||
<p style="text-align: center;">Deleting your account is an irreversible action. You cannot recover your account once this has been done.</p>
|
<p style="text-align: center;">Deleting your account is an irreversible action. You cannot recover your account once this has been done.</p>
|
||||||
<p style="text-align: center;">This will delete your account from our database, not from your Wii U or Cemu. You will need to manually remove it from these.</p>
|
<p style="text-align: center;">This will delete your account from our database, not from your Wii U or Cemu. You will need to manually remove it from these.</p>
|
||||||
<div style="display: flex; flex-direction: row; padding: 8px; justify-content: center;">
|
<div style="display: flex; flex-direction: row; padding: 8px; justify-content: center;">
|
||||||
<button id="confirm-delete-button" style="width: 300px; font-size: 32px;" class="delete-button">Delete Account</button>
|
<button id="confirm-delete-button" style="width: 300px; font-size: 32px;" class="delete-button" onclick="deleteAccount()">Delete Account</button>
|
||||||
<button id="cancel-delete-button" style="width: 300px; font-size: 32px;" onclick="hideDeleteWarning()">Cancel</button>
|
<button id="cancel-delete-button" style="width: 300px; font-size: 32px;" onclick="hideDeleteWarning()">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,21 @@ function hideDeleteWarning() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteAccount() {
|
async function deleteAccount() {
|
||||||
let token = await getToken(username, password);
|
let token;
|
||||||
|
|
||||||
|
let expiryStr = sessionStorage.getItem("authExpires");
|
||||||
|
if (expiryStr) { // Expiry exists so token should exist
|
||||||
|
let expiry = new Date(expiryStr);
|
||||||
|
if (expiry < new Date()) { // Expired token
|
||||||
|
window.location.href = "/account/login?redirect=/account"
|
||||||
|
} else if (!token) { // Expiry Saved but No Token (shouldn't be possible but it'll be caught if it happens)
|
||||||
|
window.location.href = "/account/login?redirect=/account"
|
||||||
|
} else {
|
||||||
|
token = sessionStorage.getItem("authToken");
|
||||||
|
}
|
||||||
|
} else { // Token Never Saved in Session
|
||||||
|
window.location.href = "/account/login?redirect=/account"
|
||||||
|
}
|
||||||
|
|
||||||
const response = await fetch("https://account.spfn.net/api/v2/users/@me/delete", {
|
const response = await fetch("https://account.spfn.net/api/v2/users/@me/delete", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue