Skip to content

Commit 1c0c6db

Browse files
Andrew Bakerclaude
andcommitted
feat: session persistence, brute-force lockout, Thumbnails social preview tab
- Fix sessions expiring on browser close: force persistent auth cookie when a custom session duration is configured (was writing a session cookie with expire=0 regardless of the server-side TTL setting) - Add brute-force account lockout: configurable failed-attempt threshold (default 5) and lockout period (default 5 min), per-username tracking via transients, admin UI panel in Login Security tab - Add Thumbnails tab: 9-point social preview URL checker, recent-posts auto- scan, Cloudflare WAF setup guide + crawler UA test + cache purge, media library auditor with one-click JPEG/PNG recompress for >300 KB images Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3f44937 commit 1c0c6db

File tree

7 files changed

+1473
-25
lines changed

7 files changed

+1473
-25
lines changed

assets/cs-login.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* ===========================================================
2-
CloudScale Code Block — Login Security admin JS v1.9.0
2+
CloudScale Code Block — Login Security admin JS v1.9.5
33
Handles: Hide Login save, 2FA site settings save,
4+
session duration, brute-force protection,
45
TOTP setup wizard, email 2FA enable/disable.
56
=========================================================== */
67
( function () {
@@ -48,6 +49,9 @@
4849
method: document.querySelector( 'input[name="cs_devtools_2fa_method"]:checked' )?.value || 'off',
4950
force_admins: document.getElementById( 'cs-2fa-force' )?.checked ? '1' : '0',
5051
session_duration: document.getElementById( 'cs-session-duration' )?.value || 'default',
52+
bf_enabled: document.getElementById( 'cs-bf-enabled' )?.checked ? '1' : '0',
53+
bf_attempts: document.getElementById( 'cs-bf-attempts' )?.value || '5',
54+
bf_lockout: document.getElementById( 'cs-bf-lockout' )?.value || '5',
5155
};
5256
}
5357

@@ -97,6 +101,35 @@
97101
} );
98102
}
99103

104+
const bfSaveBtn = document.getElementById( 'cs-bf-save' );
105+
const bfSaved = document.getElementById( 'cs-bf-saved' );
106+
const bfEnabled = document.getElementById( 'cs-bf-enabled' );
107+
const bfOptions = document.getElementById( 'cs-bf-options' );
108+
109+
// Toggle numeric fields based on the enable checkbox.
110+
if ( bfEnabled && bfOptions ) {
111+
const syncBfOptions = () => { bfOptions.style.opacity = bfEnabled.checked ? '' : '0.4'; };
112+
syncBfOptions();
113+
bfEnabled.addEventListener( 'change', syncBfOptions );
114+
}
115+
116+
if ( bfSaveBtn ) {
117+
bfSaveBtn.addEventListener( 'click', () => {
118+
bfSaveBtn.disabled = true;
119+
post( 'cs_devtools_login_save', collectLoginPayload() ).then( res => {
120+
bfSaveBtn.disabled = false;
121+
if ( res.success ) {
122+
flash( bfSaved, true );
123+
} else {
124+
alert( res.data || 'Save failed.' );
125+
}
126+
} ).catch( () => {
127+
bfSaveBtn.disabled = false;
128+
alert( 'Save failed. Check your connection.' );
129+
} );
130+
} );
131+
}
132+
100133
if ( twoFaSaveBtn ) {
101134
twoFaSaveBtn.addEventListener( 'click', () => {
102135
twoFaSaveBtn.disabled = true;

assets/cs-thumbnails.js

Lines changed: 375 additions & 0 deletions
Large diffs are not rendered by default.

blocks/code/block.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"default": ""
3333
}
3434
},
35-
"textdomain": "cs-code-block",
35+
"textdomain": "cloudscale-devtools",
3636
"editorStyle": "cs-code-block-editor",
3737
"style": "cs-code-block-frontend",
3838
"viewScript": "cs-code-block-frontend"

blocks/code/editor.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,23 +224,23 @@
224224

225225
return el( Fragment, {},
226226
el( InspectorControls, {},
227-
el( PanelBody, { title: __( 'Code Settings', 'cs-code-block' ), initialOpen: true },
227+
el( PanelBody, { title: __( 'Code Settings', 'cloudscale-devtools' ), initialOpen: true },
228228
el( SelectControl, {
229-
label: __( 'Language', 'cs-code-block' ),
230-
help: __( 'Leave on Auto Detect to let highlight.js guess the language.', 'cs-code-block' ),
229+
label: __( 'Language', 'cloudscale-devtools' ),
230+
help: __( 'Leave on Auto Detect to let highlight.js guess the language.', 'cloudscale-devtools' ),
231231
value: attributes.language,
232232
options: languageOptions,
233233
onChange: function( val ) { props.setAttributes( { language: val } ); }
234234
} ),
235235
el( TextControl, {
236-
label: __( 'Title', 'cs-code-block' ),
237-
help: __( 'Optional label shown above the code (e.g. filename).', 'cs-code-block' ),
236+
label: __( 'Title', 'cloudscale-devtools' ),
237+
help: __( 'Optional label shown above the code (e.g. filename).', 'cloudscale-devtools' ),
238238
value: attributes.title,
239239
onChange: function( val ) { props.setAttributes( { title: val } ); }
240240
} ),
241241
el( SelectControl, {
242-
label: __( 'Dark / Light Mode', 'cs-code-block' ),
243-
help: __( 'Override for this block. The color theme is set site wide in Tools > CloudScale Code and SQL.', 'cs-code-block' ),
242+
label: __( 'Dark / Light Mode', 'cloudscale-devtools' ),
243+
help: __( 'Override for this block. The color theme is set site wide in Tools > CloudScale Code and SQL.', 'cloudscale-devtools' ),
244244
value: attributes.theme,
245245
options: themeOptions,
246246
onChange: function( val ) { props.setAttributes( { theme: val } ); }
@@ -266,19 +266,19 @@
266266
el( 'button', {
267267
className: 'cs-code-editor-btn cs-code-editor-btn-copy',
268268
type: 'button',
269-
title: __( 'Copy code to clipboard', 'cs-code-block' ),
269+
title: __( 'Copy code to clipboard', 'cloudscale-devtools' ),
270270
onClick: onCopyCode
271271
}, getCopyLabel ),
272272
el( 'button', {
273273
className: 'cs-code-editor-btn cs-code-editor-btn-paste',
274274
type: 'button',
275-
title: __( 'Paste clipboard content', 'cs-code-block' ),
275+
title: __( 'Paste clipboard content', 'cloudscale-devtools' ),
276276
onClick: onPasteCode
277277
}, 'Paste' ),
278278
el( 'button', {
279279
className: 'cs-code-editor-btn cs-code-editor-btn-clear',
280280
type: 'button',
281-
title: __( 'Clear all code', 'cs-code-block' ),
281+
title: __( 'Clear all code', 'cloudscale-devtools' ),
282282
onClick: onClearCode
283283
}, 'Clear' )
284284
)
@@ -289,7 +289,7 @@
289289
onChange: onChangeCode,
290290
onKeyDown: onKeyDown,
291291
onPaste: onPasteCode,
292-
placeholder: __( 'Paste or type your code here...', 'cs-code-block' ),
292+
placeholder: __( 'Paste or type your code here...', 'cloudscale-devtools' ),
293293
rows: Math.max( 8, ( ( attributes.content || '' ).split( '\n' ).length || 1 ) + 2 ),
294294
spellCheck: false,
295295
autoComplete: 'off',

0 commit comments

Comments
 (0)