mirror of
https://gitlab.com/commento/commento.git
synced 2025-06-28 22:55:39 -04:00
api, frontend: add account deletion
Closes https://gitlab.com/commento/commento/issues/120
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
<div id="navbar" class="navbar">
|
||||
<a href="[[[.Origin]]]/" class="navbar-item navbar-logo-text"><img src="[[[.CdnPrefix]]]/images/logo.svg" class="navbar-logo">Commento</a>
|
||||
<div class="navbar-item">
|
||||
<a href="[[[.Origin]]]/settings" class="navbar-item">Settings</a>
|
||||
<a href="[[[.Origin]]]/logout" class="navbar-item">Logout</a>
|
||||
<div class="float-right"><b><div id="owner-name"></div></b></div>
|
||||
</div>
|
||||
|
@ -70,6 +70,14 @@ const jsCompileMap = {
|
||||
"js/dashboard-danger.js",
|
||||
"js/dashboard-export.js",
|
||||
],
|
||||
"js/settings.js": [
|
||||
"js/constants.js",
|
||||
"js/utils.js",
|
||||
"js/http.js",
|
||||
"js/errors.js",
|
||||
"js/self.js",
|
||||
"js/settings.js"
|
||||
],
|
||||
"js/logout.js": [
|
||||
"js/constants.js",
|
||||
"js/utils.js",
|
||||
|
@ -33,12 +33,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Shows messages produced from account deletion.
|
||||
function displayDeletedOwner() {
|
||||
var deleted = global.paramGet("deleted");
|
||||
|
||||
if (deleted === "true") {
|
||||
$("#msg").html("Your account has been deleted.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Shows email confirmation and password reset messages, if any.
|
||||
global.displayMessages = function() {
|
||||
displayConfirmedEmail();
|
||||
displayChangedPassword();
|
||||
displaySignedUp();
|
||||
displayDeletedOwner();
|
||||
};
|
||||
|
||||
|
||||
|
54
frontend/js/settings.js
Normal file
54
frontend/js/settings.js
Normal file
@ -0,0 +1,54 @@
|
||||
(function (global, document) {
|
||||
"use strict";
|
||||
|
||||
(document);
|
||||
|
||||
global.vueConstruct = function(callback) {
|
||||
var reactiveData = {
|
||||
hasSource: global.owner.hasSource,
|
||||
lastFour: global.owner.lastFour,
|
||||
};
|
||||
|
||||
global.settings = new Vue({
|
||||
el: "#settings",
|
||||
data: reactiveData,
|
||||
});
|
||||
|
||||
if (callback !== undefined) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
global.settingShow = function(setting) {
|
||||
$(".pane-setting").removeClass("selected");
|
||||
$(".view").hide();
|
||||
$("#" + setting).addClass("selected");
|
||||
$("#" + setting + "-view").show();
|
||||
};
|
||||
|
||||
global.deleteOwnerHandler = function() {
|
||||
if (!confirm("Are you absolutely sure you want to delete your account?")) {
|
||||
return;
|
||||
}
|
||||
|
||||
var json = {
|
||||
"ownerToken": global.cookieGet("commentoOwnerToken"),
|
||||
}
|
||||
|
||||
$("#delete-owner-button").prop("disabled", true);
|
||||
$("#delete-owner-button").text("Deleting...");
|
||||
global.post(global.origin + "/api/owner/delete", json, function(resp) {
|
||||
if (!resp.success) {
|
||||
$("#delete-owner-button").prop("disabled", false);
|
||||
$("#delete-owner-button").text("Delete Account");
|
||||
global.globalErrorShow(resp.message);
|
||||
$("#error-message").text(resp.message);
|
||||
return;
|
||||
}
|
||||
|
||||
global.cookieDelete("commentoOwnerToken");
|
||||
document.location = global.origin + "/login?deleted=true";
|
||||
});
|
||||
};
|
||||
|
||||
} (window.commento, document));
|
@ -84,7 +84,7 @@ body {
|
||||
margin: 8px;
|
||||
|
||||
.left {
|
||||
padding: 8px;
|
||||
padding: 8px 16px;
|
||||
|
||||
.title {
|
||||
font-weight: bold;
|
||||
|
90
frontend/settings.html
Normal file
90
frontend/settings.html
Normal file
@ -0,0 +1,90 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="[[[.CdnPrefix]]]/js/jquery.js"></script>
|
||||
<script src="[[[.CdnPrefix]]]/js/vue.js"></script>
|
||||
<script src="[[[.CdnPrefix]]]/js/highlight.js"></script>
|
||||
<script src="[[[.CdnPrefix]]]/js/chartist.js"></script>
|
||||
<script src="[[[.CdnPrefix]]]/js/settings.js"></script>
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
<link rel="icon" href="[[[.CdnPrefix]]]/images/120x120.png">
|
||||
<link rel="stylesheet" href="[[[.CdnPrefix]]]/css/chartist.css">
|
||||
<link rel="stylesheet" href="[[[.CdnPrefix]]]/css/dashboard.css">
|
||||
<title>Commento: Settings</title>
|
||||
</head>
|
||||
|
||||
<div id="navbar" class="navbar">
|
||||
<a href="[[[.Origin]]]/" class="navbar-item navbar-logo-text"><img src="[[[.CdnPrefix]]]/images/logo.svg" class="navbar-logo">Commento</a>
|
||||
<div class="navbar-item">
|
||||
<a href="[[[.Origin]]]/dashboard" class="navbar-item">Dashboard</a>
|
||||
<a href="[[[.Origin]]]/logout" class="navbar-item">Logout</a>
|
||||
<div class="float-right"><b><div id="owner-name"></div></b></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.onload = function() {
|
||||
window.commento.selfGet(function() {
|
||||
window.commento.vueConstruct(function() {
|
||||
window.commento.settingShow("delete-owner");
|
||||
});
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="global-error" id="global-error"></div>
|
||||
<div class="global-ok" id="global-ok"></div>
|
||||
|
||||
<div id="settings" class="dashboard-container">
|
||||
<div class="pane-left">
|
||||
<div class="pane-setting" id="delete-owner" onclick="window.commento.settingShow('delete-owner')">
|
||||
<div class="pane-setting-inside">
|
||||
<div class="setting-title">Delete Account</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pane-right pane-right-lefter">
|
||||
<div id="delete-owner-view" class="view hidden">
|
||||
<div class="view-inside">
|
||||
<div class="mid-view">
|
||||
<div class="center center-title">
|
||||
Delete Account
|
||||
</div>
|
||||
|
||||
<div class="action-buttons-container">
|
||||
<div class="action-buttons">
|
||||
<div class="action-button">
|
||||
<div class="left">
|
||||
<div class="title">
|
||||
Delete Account
|
||||
</div>
|
||||
<div class="subtitle">
|
||||
This will permanently delete your account and any data associated with your account. You must first delete all domains in the dashboard before doing this.
|
||||
</div>
|
||||
</div>
|
||||
<div class="right">
|
||||
<button onclick="document.location.hash='#delete-owner-modal'" class="button big-red-button">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="delete-owner-modal" class="modal-window">
|
||||
<div class="inside">
|
||||
<a href="#modal-close" title="Close" class="modal-close"></a>
|
||||
<div class="modal-title">Delete Accont</div>
|
||||
<div class="modal-subtitle">
|
||||
Are you absolutely sure you want to delete your account? This is a permanent change; there is no way to recover your account or any data associated with it.
|
||||
</div>
|
||||
<div class="modal-contents center">
|
||||
<button id="delete-owner-button" class="button big-red-button" onclick="window.commento.deleteOwnerHandler()">Delete Account</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</html>
|
Reference in New Issue
Block a user