ultimate-jekyll-manager 0.0.117 → 0.0.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +616 -138
- package/README.md +108 -0
- package/TODO.md +1 -1
- package/dist/assets/js/core/auth.js +8 -11
- package/dist/assets/js/core/cookieconsent.js +24 -17
- package/dist/assets/js/core/exit-popup.js +15 -12
- package/dist/assets/js/core/social-sharing.js +8 -4
- package/dist/assets/js/libs/auth/pages.js +14 -13
- package/dist/assets/js/libs/dev.js +192 -129
- package/dist/assets/js/libs/prerendered-icons.js +27 -0
- package/dist/assets/js/pages/account/index.js +4 -3
- package/dist/assets/js/pages/account/sections/api-keys.js +2 -6
- package/dist/assets/js/pages/account/sections/connections.js +101 -59
- package/dist/assets/js/pages/account/sections/delete.js +83 -84
- package/dist/assets/js/pages/account/sections/referrals.js +29 -29
- package/dist/assets/js/pages/account/sections/security.js +51 -71
- package/dist/assets/js/pages/admin/notifications/new/index.js +17 -10
- package/dist/assets/js/pages/blog/index.js +7 -5
- package/dist/assets/js/pages/contact/index.js +6 -33
- package/dist/assets/js/pages/download/index.js +3 -2
- package/dist/assets/js/pages/payment/checkout/index.js +6 -6
- package/dist/assets/js/pages/payment/checkout/modules/processors-main.js +2 -2
- package/dist/assets/js/pages/payment/checkout/modules/session.js +4 -4
- package/dist/assets/js/pages/pricing/index.js +5 -2
- package/dist/assets/themes/classy/css/components/_cards.scss +2 -2
- package/dist/defaults/_.env +6 -0
- package/dist/defaults/_.gitignore +7 -1
- package/dist/defaults/dist/_includes/core/body.html +18 -3
- package/dist/defaults/dist/_includes/core/foot.html +1 -0
- package/dist/defaults/dist/_includes/themes/classy/frontend/sections/nav.html +51 -36
- package/dist/defaults/dist/_layouts/blueprint/admin/notifications/new.html +13 -2
- package/dist/defaults/dist/_layouts/themes/classy/frontend/pages/about.html +84 -42
- package/dist/defaults/dist/_layouts/themes/classy/frontend/pages/account/index.html +67 -35
- package/dist/defaults/dist/_layouts/themes/classy/frontend/pages/blog/index.html +72 -58
- package/dist/defaults/dist/_layouts/themes/classy/frontend/pages/blog/post.html +46 -29
- package/dist/defaults/dist/_layouts/themes/classy/frontend/pages/contact.html +36 -16
- package/dist/defaults/dist/_layouts/themes/classy/frontend/pages/download.html +111 -73
- package/dist/defaults/dist/_layouts/themes/classy/frontend/pages/index.html +111 -56
- package/dist/defaults/dist/_layouts/themes/classy/frontend/pages/pricing.html +127 -81
- package/dist/defaults/dist/pages/pricing.md +7 -0
- package/dist/defaults/dist/pages/test/libraries/lazy-loading.html +1 -1
- package/dist/gulp/tasks/defaults.js +210 -1
- package/firebase-debug.log +504 -0
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Connections section module for OAuth account linking
|
|
2
2
|
import { FormManager } from '__main_assets__/js/libs/form-manager.js';
|
|
3
|
-
import
|
|
3
|
+
import authorizedFetch from '__main_assets__/js/libs/authorized-fetch.js';;
|
|
4
4
|
|
|
5
5
|
let webManager = null;
|
|
6
6
|
let appData = null;
|
|
@@ -32,6 +32,8 @@ export async function loadData(account, sharedAppData) {
|
|
|
32
32
|
|
|
33
33
|
// Display available and connected OAuth providers
|
|
34
34
|
function displayConnections() {
|
|
35
|
+
console.log('[DEBUG] displayConnections() called');
|
|
36
|
+
|
|
35
37
|
// Hide loading state
|
|
36
38
|
const $loading = document.getElementById('connections-loading');
|
|
37
39
|
if ($loading) {
|
|
@@ -40,6 +42,7 @@ function displayConnections() {
|
|
|
40
42
|
|
|
41
43
|
// Check if appData is loaded
|
|
42
44
|
if (!appData) {
|
|
45
|
+
console.log('[DEBUG] No appData, showing loading state');
|
|
43
46
|
// Show loading if no app data yet
|
|
44
47
|
if ($loading) {
|
|
45
48
|
$loading.classList.remove('d-none');
|
|
@@ -51,36 +54,51 @@ function displayConnections() {
|
|
|
51
54
|
const availableProviders = appData?.oauth2 || {};
|
|
52
55
|
const userConnections = accountData?.oauth2 || {};
|
|
53
56
|
|
|
57
|
+
console.log('[DEBUG] Available OAuth providers:', availableProviders);
|
|
58
|
+
console.log('[DEBUG] User connections:', userConnections);
|
|
59
|
+
|
|
54
60
|
// Check if any providers are configured
|
|
55
61
|
let hasEnabledProviders = false;
|
|
56
62
|
|
|
57
63
|
// Process each supported provider
|
|
58
64
|
supportedProviders.forEach(providerId => {
|
|
65
|
+
console.log(`[DEBUG] Processing provider: ${providerId}`);
|
|
66
|
+
|
|
59
67
|
const providerSettings = availableProviders[providerId];
|
|
60
68
|
const $providerElement = document.getElementById(`connection-${providerId}`);
|
|
61
69
|
|
|
70
|
+
console.log(`[DEBUG] ${providerId} - providerSettings:`, providerSettings);
|
|
71
|
+
console.log(`[DEBUG] ${providerId} - providerSettings.enabled:`, providerSettings?.enabled);
|
|
72
|
+
console.log(`[DEBUG] ${providerId} - $providerElement exists:`, !!$providerElement);
|
|
73
|
+
|
|
62
74
|
if (!$providerElement) {
|
|
75
|
+
console.warn(`[DEBUG] ${providerId} - Provider element not found in DOM`);
|
|
63
76
|
return;
|
|
64
77
|
}
|
|
65
78
|
|
|
66
79
|
// Check if provider is enabled
|
|
67
80
|
const isEnabled = providerSettings && providerSettings.enabled !== false;
|
|
81
|
+
console.log(`[DEBUG] ${providerId} - isEnabled:`, isEnabled);
|
|
68
82
|
|
|
69
83
|
if (isEnabled) {
|
|
70
84
|
hasEnabledProviders = true;
|
|
71
85
|
|
|
72
|
-
// Show the provider element
|
|
86
|
+
// Show the provider element first
|
|
87
|
+
console.log(`[DEBUG] ${providerId} - Removing d-none class`);
|
|
73
88
|
$providerElement.classList.remove('d-none');
|
|
74
89
|
|
|
75
|
-
//
|
|
76
|
-
|
|
90
|
+
// Initialize FormManager for this provider before updating status
|
|
91
|
+
console.log(`[DEBUG] ${providerId} - About to initialize FormManager`);
|
|
92
|
+
initializeProviderForm(providerId);
|
|
93
|
+
|
|
94
|
+
// Update provider status based on user connection
|
|
77
95
|
const userConnection = userConnections[providerId];
|
|
96
|
+
console.log(`[DEBUG] ${providerId} - userConnection:`, userConnection);
|
|
97
|
+
console.log(`[DEBUG] ${providerId} - About to update provider status`);
|
|
78
98
|
updateProviderStatus(providerId, userConnection, providerSettings);
|
|
79
|
-
|
|
80
|
-
// Initialize FormManager AFTER setting correct button state
|
|
81
|
-
initializeProviderForm(providerId);
|
|
82
99
|
} else {
|
|
83
100
|
// Hide disabled providers
|
|
101
|
+
console.log(`[DEBUG] ${providerId} - Provider disabled, adding d-none class`);
|
|
84
102
|
$providerElement.classList.add('d-none');
|
|
85
103
|
}
|
|
86
104
|
});
|
|
@@ -98,14 +116,28 @@ function displayConnections() {
|
|
|
98
116
|
|
|
99
117
|
// Update provider status display
|
|
100
118
|
function updateProviderStatus(providerId, userConnection, providerSettings) {
|
|
119
|
+
console.log(`[DEBUG] updateProviderStatus() called for ${providerId}`);
|
|
120
|
+
console.log(`[DEBUG] ${providerId} - userConnection:`, userConnection);
|
|
121
|
+
console.log(`[DEBUG] ${providerId} - userConnection truthy:`, !!userConnection);
|
|
122
|
+
console.log(`[DEBUG] ${providerId} - userConnection.identity:`, userConnection?.identity);
|
|
123
|
+
console.log(`[DEBUG] ${providerId} - providerSettings:`, providerSettings);
|
|
124
|
+
|
|
101
125
|
const $status = document.getElementById(`${providerId}-connection-status`);
|
|
102
126
|
const $description = document.getElementById(`${providerId}-connection-description`);
|
|
103
127
|
const $form = document.getElementById(`connection-form-${providerId}`);
|
|
104
|
-
const $
|
|
105
|
-
const $
|
|
106
|
-
|
|
128
|
+
const $connectButton = $form?.querySelector('button[data-action="connect"]');
|
|
129
|
+
const $disconnectButton = $form?.querySelector('button[data-action="disconnect"]');
|
|
130
|
+
|
|
131
|
+
console.log(`[DEBUG] ${providerId} - DOM elements found:`, {
|
|
132
|
+
$status: !!$status,
|
|
133
|
+
$description: !!$description,
|
|
134
|
+
$form: !!$form,
|
|
135
|
+
$connectButton: !!$connectButton,
|
|
136
|
+
$disconnectButton: !!$disconnectButton
|
|
137
|
+
});
|
|
107
138
|
|
|
108
139
|
const isConnected = userConnection && userConnection.identity;
|
|
140
|
+
console.log(`[DEBUG] ${providerId} - isConnected:`, isConnected);
|
|
109
141
|
|
|
110
142
|
// Always show description on the left
|
|
111
143
|
if ($description) {
|
|
@@ -117,9 +149,8 @@ function updateProviderStatus(providerId, userConnection, providerSettings) {
|
|
|
117
149
|
facebook: 'Connect your Facebook account for social features'
|
|
118
150
|
};
|
|
119
151
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|| `Connect your ${providerId.charAt(0).toUpperCase() + providerId.slice(1)} account`;
|
|
152
|
+
// Use provider description or fallback to default
|
|
153
|
+
const descriptionText = providerSettings?.description || defaultDescriptions[providerId] || `Connect your ${providerId.charAt(0).toUpperCase() + providerId.slice(1)} account`;
|
|
123
154
|
$description.textContent = descriptionText;
|
|
124
155
|
$description.classList.remove('d-none');
|
|
125
156
|
}
|
|
@@ -144,39 +175,26 @@ function updateProviderStatus(providerId, userConnection, providerSettings) {
|
|
|
144
175
|
$status.textContent = statusText;
|
|
145
176
|
$status.classList.remove('d-none');
|
|
146
177
|
} else {
|
|
147
|
-
// Not connected - hide status
|
|
178
|
+
// Not connected - hide status text
|
|
148
179
|
$status.textContent = '';
|
|
149
180
|
$status.classList.add('d-none');
|
|
150
181
|
}
|
|
151
182
|
}
|
|
152
183
|
|
|
153
|
-
|
|
184
|
+
// Show/hide appropriate button
|
|
185
|
+
if ($connectButton && $disconnectButton) {
|
|
186
|
+
console.log(`[DEBUG] ${providerId} - Updating buttons. isConnected:`, isConnected);
|
|
187
|
+
|
|
154
188
|
if (isConnected) {
|
|
155
|
-
//
|
|
156
|
-
$
|
|
157
|
-
$
|
|
158
|
-
|
|
159
|
-
$action.value = 'disconnect';
|
|
160
|
-
|
|
161
|
-
// Replace icon
|
|
162
|
-
const $icon = $button.querySelector('.fa-icon');
|
|
163
|
-
if ($icon) {
|
|
164
|
-
$icon.classList.remove('fa-link');
|
|
165
|
-
$icon.classList.add('fa-unlink');
|
|
166
|
-
}
|
|
189
|
+
// Hide connect button, show disconnect button
|
|
190
|
+
$connectButton.classList.add('d-none');
|
|
191
|
+
$disconnectButton.classList.remove('d-none');
|
|
192
|
+
console.log(`[DEBUG] ${providerId} - Showing disconnect button`);
|
|
167
193
|
} else {
|
|
168
|
-
//
|
|
169
|
-
$
|
|
170
|
-
$
|
|
171
|
-
|
|
172
|
-
$action.value = 'connect';
|
|
173
|
-
|
|
174
|
-
// Replace icon
|
|
175
|
-
const $icon = $button.querySelector('.fa-icon');
|
|
176
|
-
if ($icon) {
|
|
177
|
-
$icon.classList.remove('fa-unlink');
|
|
178
|
-
$icon.classList.add('fa-link');
|
|
179
|
-
}
|
|
194
|
+
// Show connect button, hide disconnect button
|
|
195
|
+
$connectButton.classList.remove('d-none');
|
|
196
|
+
$disconnectButton.classList.add('d-none');
|
|
197
|
+
console.log(`[DEBUG] ${providerId} - Showing connect button`);
|
|
180
198
|
}
|
|
181
199
|
}
|
|
182
200
|
}
|
|
@@ -185,12 +203,13 @@ function updateProviderStatus(providerId, userConnection, providerSettings) {
|
|
|
185
203
|
function getConnectionDisplayName(connection) {
|
|
186
204
|
if (!connection || !connection.identity) return 'Unknown';
|
|
187
205
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
206
|
+
// Try different fields based on provider
|
|
207
|
+
return connection.identity.global_name ||
|
|
208
|
+
connection.identity.username ||
|
|
209
|
+
connection.identity.name ||
|
|
210
|
+
connection.identity.email ||
|
|
211
|
+
connection.identity.id ||
|
|
212
|
+
'Connected';
|
|
194
213
|
}
|
|
195
214
|
|
|
196
215
|
// Initialize FormManager for a provider
|
|
@@ -205,9 +224,12 @@ function initializeProviderForm(providerId) {
|
|
|
205
224
|
|
|
206
225
|
// Skip if already initialized
|
|
207
226
|
if (connectionForms.has(providerId)) {
|
|
227
|
+
console.log(`FormManager already initialized for ${providerId}`);
|
|
208
228
|
return;
|
|
209
229
|
}
|
|
210
230
|
|
|
231
|
+
console.log(`Initializing FormManager for ${providerId}`);
|
|
232
|
+
|
|
211
233
|
// Create new FormManager
|
|
212
234
|
const formManager = new FormManager(`#${formId}`, {
|
|
213
235
|
autoDisable: true,
|
|
@@ -217,14 +239,32 @@ function initializeProviderForm(providerId) {
|
|
|
217
239
|
// Store the FormManager instance
|
|
218
240
|
connectionForms.set(providerId, formManager);
|
|
219
241
|
|
|
242
|
+
// Listen for state changes to update button after FormManager is ready
|
|
243
|
+
formManager.addEventListener('statechange', (event) => {
|
|
244
|
+
const { status } = event.detail;
|
|
245
|
+
console.log(`[DEBUG] ${providerId} - FormManager state changed to:`, status);
|
|
246
|
+
|
|
247
|
+
// When FormManager transitions to ready, update the button status
|
|
248
|
+
if (status === 'ready') {
|
|
249
|
+
console.log(`[DEBUG] ${providerId} - FormManager is ready, updating button status`);
|
|
250
|
+
const userConnection = accountData?.oauth2?.[providerId];
|
|
251
|
+
const providerSettings = appData?.oauth2?.[providerId];
|
|
252
|
+
updateProviderStatus(providerId, userConnection, providerSettings);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
220
256
|
// Handle form submission
|
|
221
257
|
formManager.addEventListener('submit', async (event) => {
|
|
222
258
|
event.preventDefault();
|
|
223
259
|
|
|
224
|
-
const { data } = event.detail;
|
|
225
|
-
const action = data.action;
|
|
260
|
+
const { data, submitButton } = event.detail;
|
|
226
261
|
const provider = data.provider;
|
|
227
262
|
|
|
263
|
+
// Determine action from the clicked button's data-action attribute
|
|
264
|
+
const action = submitButton?.getAttribute('data-action');
|
|
265
|
+
|
|
266
|
+
console.log(`[DEBUG] ${providerId} - Form submitted. Action:`, action, 'Provider:', provider);
|
|
267
|
+
|
|
228
268
|
try {
|
|
229
269
|
if (action === 'connect') {
|
|
230
270
|
await handleConnect(provider);
|
|
@@ -233,10 +273,13 @@ function initializeProviderForm(providerId) {
|
|
|
233
273
|
if (success) {
|
|
234
274
|
// Reset form state and update UI after successful disconnect
|
|
235
275
|
formManager.setFormState('ready');
|
|
276
|
+
// Get provider settings to pass for description display
|
|
236
277
|
const providerSettings = appData?.oauth2?.[provider];
|
|
237
278
|
updateProviderStatus(provider, null, providerSettings);
|
|
238
279
|
}
|
|
239
280
|
}
|
|
281
|
+
|
|
282
|
+
// Success - FormManager will handle state automatically
|
|
240
283
|
} catch (error) {
|
|
241
284
|
// Show error and reset form state
|
|
242
285
|
formManager.showError(error);
|
|
@@ -252,19 +295,15 @@ async function handleConnect(providerId) {
|
|
|
252
295
|
throw new Error('This connection service is not available.');
|
|
253
296
|
}
|
|
254
297
|
|
|
255
|
-
// Get user token
|
|
256
|
-
const token = await webManager.auth().getIdToken();
|
|
257
|
-
|
|
258
298
|
// Get scope from provider settings (pass as array)
|
|
259
299
|
const scope = provider.scope || [];
|
|
260
300
|
|
|
261
|
-
const response = await
|
|
301
|
+
const response = await authorizedFetch(getApiUrl(), {
|
|
262
302
|
method: 'POST',
|
|
263
303
|
timeout: 30000,
|
|
264
304
|
response: 'json',
|
|
265
305
|
tries: 2,
|
|
266
306
|
body: {
|
|
267
|
-
authenticationToken: token,
|
|
268
307
|
command: 'user:oauth2',
|
|
269
308
|
payload: {
|
|
270
309
|
redirect: false,
|
|
@@ -276,6 +315,8 @@ async function handleConnect(providerId) {
|
|
|
276
315
|
},
|
|
277
316
|
});
|
|
278
317
|
|
|
318
|
+
console.log('OAuth connect response:', response);
|
|
319
|
+
|
|
279
320
|
// For authorize requests, server returns an object with URL to redirect to
|
|
280
321
|
if (response.url) {
|
|
281
322
|
window.location.href = response.url;
|
|
@@ -296,20 +337,16 @@ async function handleDisconnect(providerId) {
|
|
|
296
337
|
throw new Error('Disconnection cancelled');
|
|
297
338
|
}
|
|
298
339
|
|
|
299
|
-
// Get user token
|
|
300
|
-
const token = await webManager.auth().getIdToken();
|
|
301
|
-
|
|
302
340
|
// Get provider settings for scope (pass as array)
|
|
303
341
|
const provider = appData?.oauth2?.[providerId] || {};
|
|
304
342
|
const scope = provider.scope || [];
|
|
305
343
|
|
|
306
|
-
const response = await
|
|
344
|
+
const response = await authorizedFetch(getApiUrl(), {
|
|
307
345
|
method: 'POST',
|
|
308
346
|
timeout: 30000,
|
|
309
347
|
response: 'json',
|
|
310
348
|
tries: 2,
|
|
311
349
|
body: {
|
|
312
|
-
authenticationToken: token,
|
|
313
350
|
command: 'user:oauth2',
|
|
314
351
|
payload: {
|
|
315
352
|
redirect: false,
|
|
@@ -321,12 +358,15 @@ async function handleDisconnect(providerId) {
|
|
|
321
358
|
},
|
|
322
359
|
});
|
|
323
360
|
|
|
361
|
+
console.log('OAuth disconnect response:', response);
|
|
362
|
+
|
|
324
363
|
if (response.success) {
|
|
325
364
|
// Update local account data
|
|
326
365
|
if (accountData.oauth2 && accountData.oauth2[providerId]) {
|
|
327
366
|
delete accountData.oauth2[providerId];
|
|
328
367
|
}
|
|
329
368
|
|
|
369
|
+
// Return success
|
|
330
370
|
return true;
|
|
331
371
|
} else {
|
|
332
372
|
throw new Error(response.message || 'Failed to disconnect');
|
|
@@ -335,6 +375,8 @@ async function handleDisconnect(providerId) {
|
|
|
335
375
|
|
|
336
376
|
// Called when section is shown
|
|
337
377
|
export function onShow() {
|
|
338
|
-
//
|
|
339
|
-
|
|
378
|
+
// Refresh connections display when section is shown
|
|
379
|
+
if (accountData && appData) {
|
|
380
|
+
displayConnections();
|
|
381
|
+
}
|
|
340
382
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// Delete account section module
|
|
2
|
-
import
|
|
2
|
+
import { FormManager } from '__main_assets__/js/libs/form-manager.js';
|
|
3
|
+
import authorizedFetch from '__main_assets__/js/libs/authorized-fetch.js';
|
|
3
4
|
|
|
4
5
|
let webManager = null;
|
|
6
|
+
let formManager = null;
|
|
5
7
|
|
|
6
8
|
// Initialize delete section
|
|
7
9
|
export async function init(wm) {
|
|
@@ -15,9 +17,21 @@ function setupDeleteAccountForm() {
|
|
|
15
17
|
const $checkbox = document.getElementById('delete-confirm-checkbox');
|
|
16
18
|
const $deleteBtn = document.getElementById('delete-account-btn');
|
|
17
19
|
const $cancelBtn = document.getElementById('cancel-delete-btn');
|
|
18
|
-
const $reason = document.getElementById('delete-reason');
|
|
19
20
|
|
|
20
|
-
if (!$form || !$checkbox || !$deleteBtn)
|
|
21
|
+
if (!$form || !$checkbox || !$deleteBtn) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Initialize FormManager
|
|
26
|
+
formManager = new FormManager('#delete-account-form', {
|
|
27
|
+
autoDisable: true,
|
|
28
|
+
showSpinner: true,
|
|
29
|
+
validateOnSubmit: false, // We'll handle validation manually due to custom confirmation flow
|
|
30
|
+
allowMultipleSubmissions: false,
|
|
31
|
+
resetOnSuccess: false,
|
|
32
|
+
submitButtonLoadingText: 'Deleting account...',
|
|
33
|
+
initialState: 'ready',
|
|
34
|
+
});
|
|
21
35
|
|
|
22
36
|
// Enable/disable delete button based on checkbox
|
|
23
37
|
$checkbox.addEventListener('change', (e) => {
|
|
@@ -32,75 +46,80 @@ function setupDeleteAccountForm() {
|
|
|
32
46
|
});
|
|
33
47
|
}
|
|
34
48
|
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
49
|
+
// Listen to FormManager submit event
|
|
50
|
+
formManager.addEventListener('submit', handleFormSubmit);
|
|
51
|
+
}
|
|
38
52
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
53
|
+
// Handle form submission
|
|
54
|
+
async function handleFormSubmit(event) {
|
|
55
|
+
// Prevent default FormManager submission
|
|
56
|
+
event.preventDefault();
|
|
44
57
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const userInput = prompt(confirmMessage);
|
|
58
|
+
const formData = event.detail.data;
|
|
59
|
+
const $checkbox = document.getElementById('delete-confirm-checkbox');
|
|
48
60
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
// Check if checkbox is checked
|
|
62
|
+
if (!$checkbox.checked) {
|
|
63
|
+
formManager.showError('Please confirm that you understand this action is permanent.');
|
|
64
|
+
formManager.setFormState('ready');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
53
67
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!finalConfirm) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
68
|
+
// Show confirmation dialog
|
|
69
|
+
const confirmMessage = `Are you absolutely sure you want to delete your account?\n\nThis action CANNOT be undone.\n\nType "DELETE" to confirm:`;
|
|
70
|
+
const userInput = prompt(confirmMessage);
|
|
60
71
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
if (userInput !== 'DELETE') {
|
|
73
|
+
formManager.showError('Account deletion cancelled. You must type "DELETE" exactly to confirm.');
|
|
74
|
+
formManager.setFormState('ready');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Final confirmation
|
|
79
|
+
const finalConfirm = confirm('This is your last chance to cancel.\n\nAre you sure you want to permanently delete your account?');
|
|
80
|
+
|
|
81
|
+
if (!finalConfirm) {
|
|
82
|
+
formManager.setFormState('ready');
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
// Send delete request to server
|
|
88
|
+
const response = await authorizedFetch(webManager.getApiUrl(), {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
timeout: 30000,
|
|
91
|
+
response: 'json',
|
|
92
|
+
tries: 2,
|
|
93
|
+
body: {
|
|
94
|
+
command: 'user:delete',
|
|
95
|
+
payload: {
|
|
96
|
+
reason: formData.reason || '',
|
|
77
97
|
confirmed: true
|
|
78
98
|
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
console.log('Delete account response:', response);
|
|
82
|
-
|
|
83
|
-
if (response.success) {
|
|
84
|
-
// Show success message
|
|
85
|
-
alert('Your account has been successfully deleted. You will now be signed out.');
|
|
86
|
-
|
|
87
|
-
// Sign out the user
|
|
88
|
-
await webManager.auth().signOut();
|
|
89
|
-
|
|
90
|
-
// Redirect to home page
|
|
91
|
-
window.location.href = '/';
|
|
92
|
-
} else {
|
|
93
|
-
throw new Error(response.message || 'Failed to delete account');
|
|
94
99
|
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
console.log('Delete account response:', response);
|
|
103
|
+
|
|
104
|
+
if (response.success) {
|
|
105
|
+
// Show success message
|
|
106
|
+
formManager.showSuccess('Your account has been successfully deleted. You will now be signed out.');
|
|
107
|
+
|
|
108
|
+
// Sign out the user
|
|
109
|
+
await webManager.auth().signOut();
|
|
110
|
+
|
|
111
|
+
// Redirect to home page
|
|
112
|
+
setTimeout(() => {
|
|
113
|
+
window.location.href = '/';
|
|
114
|
+
}, 1500);
|
|
115
|
+
} else {
|
|
116
|
+
throw new Error(response.message || 'Failed to delete account');
|
|
102
117
|
}
|
|
103
|
-
})
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error('Failed to delete account:', error);
|
|
120
|
+
formManager.showError(`Failed to delete account: ${error.message}`);
|
|
121
|
+
formManager.setFormState('ready');
|
|
122
|
+
}
|
|
104
123
|
}
|
|
105
124
|
|
|
106
125
|
// Load delete section data (if needed)
|
|
@@ -111,25 +130,5 @@ export async function loadData(account) {
|
|
|
111
130
|
|
|
112
131
|
// Called when section is shown
|
|
113
132
|
export function onShow() {
|
|
114
|
-
// Reset form when shown
|
|
115
|
-
const $form = document.getElementById('delete-account-form');
|
|
116
|
-
const $checkbox = document.getElementById('delete-confirm-checkbox');
|
|
117
|
-
const $deleteBtn = document.getElementById('delete-account-btn');
|
|
118
|
-
const $reason = document.getElementById('delete-reason');
|
|
119
133
|
|
|
120
|
-
|
|
121
|
-
$form.reset();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if ($checkbox) {
|
|
125
|
-
$checkbox.checked = false;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if ($deleteBtn) {
|
|
129
|
-
$deleteBtn.disabled = true;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if ($reason) {
|
|
133
|
-
$reason.value = '';
|
|
134
|
-
}
|
|
135
|
-
}
|
|
134
|
+
}
|