Add user delete button
This commit is contained in:
@@ -102,6 +102,39 @@ let name_change = {
|
|||||||
return {success: true, message: "Success! You are now known as "+fields.new_username}
|
return {success: true, message: "Success! You are now known as "+fields.new_username}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let delete_account = {
|
||||||
|
name: "delete_account",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: "description",
|
||||||
|
label: "Description",
|
||||||
|
type: "description",
|
||||||
|
description: `When you delete your pixeldrain account you will be
|
||||||
|
logged out on all of your devices. Your account will be
|
||||||
|
scheduled for deletion in seven days. If you log back in to your
|
||||||
|
account during those seven days the deletion will be canceled.
|
||||||
|
<br/><br/>
|
||||||
|
If you have an active Pro subscription you need to end that
|
||||||
|
separately through your Patreon account. Deleting your
|
||||||
|
pixeldrain account will not cancel the subscription.`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
submit_red: true,
|
||||||
|
submit_label: `<i class="icon">delete</i> Delete`,
|
||||||
|
on_submit: async fields => {
|
||||||
|
const resp = await fetch(
|
||||||
|
window.api_endpoint+"/user",
|
||||||
|
{ method: "DELETE" }
|
||||||
|
);
|
||||||
|
if(resp.status >= 400) {
|
||||||
|
return {error_json: await resp.json()}
|
||||||
|
}
|
||||||
|
setTimeout(() => { window.location = "/" }, 6000)
|
||||||
|
return {success: true, message: "Success! Your account has been scheduled for deletion in 7 days"}
|
||||||
|
},
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@@ -120,6 +153,11 @@ let name_change = {
|
|||||||
<div class="highlight_dark">
|
<div class="highlight_dark">
|
||||||
<Form config={name_change}></Form>
|
<Form config={name_change}></Form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h2>Delete account</h2>
|
||||||
|
<div class="highlight_dark">
|
||||||
|
<Form config={delete_account}></Form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@@ -47,6 +47,8 @@ let submit = async (event) => {
|
|||||||
} else {
|
} else {
|
||||||
field_values[field.name] = field.binding
|
field_values[field.name] = field.binding
|
||||||
}
|
}
|
||||||
|
} else if (field.type === "description") {
|
||||||
|
field_values[field.name] = ""
|
||||||
} else {
|
} else {
|
||||||
field_values[field.name] = field.binding.value
|
field_values[field.name] = field.binding.value
|
||||||
}
|
}
|
||||||
@@ -143,7 +145,7 @@ let handle_errors = (response) => {
|
|||||||
style="width: 100%; height: 10em; resize: vertical;"
|
style="width: 100%; height: 10em; resize: vertical;"
|
||||||
>{field.default_value}</textarea>
|
>{field.default_value}</textarea>
|
||||||
</td>
|
</td>
|
||||||
{:else}
|
{:else if field.type !== "description"}
|
||||||
<td>{field.label}</td>
|
<td>{field.label}</td>
|
||||||
<td>
|
<td>
|
||||||
{#if field.type === "text"}
|
{#if field.type === "text"}
|
||||||
@@ -205,8 +207,6 @@ let handle_errors = (response) => {
|
|||||||
checked={val === field.default_value}/>
|
checked={val === field.default_value}/>
|
||||||
<label for="input_{field.name}_choice_{val}">{val}</label><br/>
|
<label for="input_{field.name}_choice_{val}">{val}</label><br/>
|
||||||
{/each}
|
{/each}
|
||||||
{:else if field.type === "description"}
|
|
||||||
{field.default_value}
|
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -214,7 +214,7 @@ let handle_errors = (response) => {
|
|||||||
{#if field.description}
|
{#if field.description}
|
||||||
<tr class="form">
|
<tr class="form">
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
{field.description}
|
{@html field.description}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/if}
|
{/if}
|
||||||
|
Reference in New Issue
Block a user