mirror of
https://github.com/wekan/wekan.git
synced 2026-11-05 01:20:07 -05:00
Fix the missing password fields at /sign-in and /sign-up.
My own regression, and a bad one: the login form had no password input.
When the Accounts pane was removed from Admin Panel / Settings - its three
settings having moved to Email and Login - its save handler was left registered on
the template that went with it:
Template.accountSettings.events({ ... }) // accountSettings no longer exists
That throws at MODULE LOAD, and because it throws, no module after it in the
client graph runs. client/features/users.js never executed, so passwordInput.jade
was never registered, and useraccounts logged
[UserAccounts] Warning no template passwordInput found!
then rendered nothing for the two fields that use it - password and
password_again. One dead reference in the Admin Panel took out the login form for
everyone.
The handler moved to Template.setting, which renders the Login pane its button
lives in.
Why nothing caught it: the file parses, every unit test passed, and the failure
only ever appears in a browser console. So the guard is new -
tests/templateHandlersExist.test.cjs walks every .js under client/components and
asserts each Template.X.events/helpers/onCreated/onRendered/onDestroyed has a
matching template(name="X") in some .jade. It ignores commented-out code (there is
a Template.cards.events() in a comment in minicard.js) and package-provided
templates. It fails on the pre-fix file.
Diagnosis notes, since "password field is missing" points nowhere near the Admin
Panel: the field was correctly registered - removeField returns the field object
and it is in addFields - and the compiled passwordInput template WAS in the served
bundle. What it was not was executed. The console error naming
Template.accountSettings is what tied the two ends together.
Thanks to xet7 !
This commit is contained in:
1 parent
a5d59a6479
commit
696c490387
3 files changed
+101
-2
No files matched your search
@@ -974,7 +974,15 @@ const accountAccessHelpers = {
|
||||
Template.email.helpers(accountAccessHelpers);
|
||||
Template.setting.helpers(accountAccessHelpers);
|
||||
|
||||
Template.accountSettings.events({
|
||||
// The accountSettings TEMPLATE was removed when its three settings moved to Email
|
||||
// and Login, but this handler was left registered on it. Template.accountSettings
|
||||
// is undefined, so the module threw at load - and because it threw, the rest of
|
||||
// the client module graph never ran: passwordInput.jade was never registered and
|
||||
// the password fields vanished from /sign-in and /sign-up.
|
||||
//
|
||||
// The button lives in the Login pane, which Template.setting renders, so the
|
||||
// handler belongs there.
|
||||
Template.setting.events({
|
||||
// Login pane: the two account-access settings that moved here.
|
||||
'click button.js-account-access-save'() {
|
||||
// Moved here from Layout with their inputs. Both are Settings fields, unlike
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"test": "meteor test --once --driver-package meteortesting:mocha",
|
||||
"test:unit:node": "node tests/filenameSanitizer.test.cjs && node tests/cardBoardConsistency.test.cjs && node tests/cardUrl.test.cjs && node tests/defaultSwimlane.test.cjs && node tests/cardMoveModifier.test.cjs && node tests/authenticationMethod.test.cjs && node tests/linkedCardTarget.test.cjs && node tests/staleWhileRevalidate.test.cjs && node tests/restArrayParam.test.cjs && node tests/minicardLabelHeight.test.cjs && node tests/dateUtils.normalizeDigits.test.cjs && node tests/reconcileBoardTeamMembers.test.cjs && node tests/rulesBoardSelector.test.cjs && node tests/ruleActionResolve.test.cjs && node tests/boardBackground.test.cjs && node tests/weekStart.test.cjs && node tests/ldapUsernameSlug.test.cjs && node tests/ldapGroupAllowlist.test.cjs && node tests/ldapConnectionRelease.test.cjs && node tests/htmljsArrayContent.test.cjs && node tests/cardDescriptionDraft.test.cjs && node tests/commentDraft.test.cjs && node tests/attachmentDeleteGuard.test.cjs && node tests/ruleMoveAction.test.cjs && node tests/snapMigrationRecovery.test.cjs && node tests/migrationAttachmentExtraction.test.cjs && node tests/attachmentRepair.test.cjs && node tests/attachmentStoragePath.test.cjs && node tests/schemaUpgradeSteps.test.cjs && node tests/cpuExec.test.cjs && node tests/cpuExecWiring.test.cjs && node tests/ferretdbHasData.test.cjs && node tests/ferretdbPolling.test.cjs && node tests/ferretdbWaitTimeout.test.cjs && node tests/ferretdbOplog.test.cjs && node tests/ferretdbOplogReset.test.cjs && node tests/ferretdbTextDataBackup.test.cjs && node tests/recoveryPlan.test.cjs && node tests/recoveryReportQuery.test.cjs && node tests/recoveryEventsJsonl.test.cjs && node tests/recoveryReportWiring.test.cjs && node tests/recoveryMaintenance.test.cjs && node tests/importMemberMapping.test.cjs && node tests/boardMemberMapPlan.test.cjs && node tests/withDeadline.test.cjs && node tests/importVirtualMembers.test.cjs && node tests/sandstormMigrationBridge.test.cjs && node tests/fileNameDisplay.test.cjs && node tests/uploadFileName.test.cjs && node tests/diskSpace.test.cjs && node tests/fileTypeCorrection.test.cjs && node tests/fileHardeningGuards.test.cjs && node tests/cpuHighTracker.test.cjs && node tests/cpuMonitorWiring.test.cjs && node tests/buttonThemeColors.test.cjs && node tests/uiDensity.test.cjs && node tests/editorSubmitKey.test.cjs && node tests/isoWeek.test.cjs && node tests/boardCopyDefaults.test.cjs && node tests/linkedCardTitle.test.cjs && node tests/commentActivity.test.cjs && node tests/swimlaneSort.test.cjs && node tests/subtaskCopy.test.cjs && node tests/subtasksDefaultBoard.test.cjs && node tests/scrollbarCss.test.cjs && node tests/minicardBidiIsolation.test.cjs && node tests/notificationCleanup.test.cjs && node tests/cardSearch.test.cjs && node tests/linkedCardMembers.test.cjs && node tests/verificationEmail.test.cjs && node tests/boardSortReorder.test.cjs && node tests/checklistItemTitles.test.cjs && node tests/swimlaneFilter.test.cjs && node tests/popupOffset.test.cjs && node tests/popupAfterConfirm.test.cjs && node tests/defaultBoard.test.cjs && node tests/upcomingUiGuards.test.cjs && node tests/linkedCardCover.test.cjs && node tests/inviteEmailLanguage.test.cjs && node tests/domainTablePage.test.cjs && node tests/mongoSelectorSafety.test.cjs && node tests/filterDateNull.test.cjs && node tests/listMoveSwimlane.test.cjs && node tests/cardDragSwimlaneScrollRefresh.test.cjs && node tests/undoRedoSelection.test.cjs && node tests/softDelete.test.cjs && node tests/globalThemeColor.test.cjs && node tests/themeCategories.test.cjs && node tests/themeColorPicker.test.cjs && node tests/uiFonts.test.cjs && node tests/sandstormAutoOpen.test.cjs && node tests/createListParams.test.cjs && node tests/addBoardTileHeight.test.cjs && node tests/multiSelectionButton.test.cjs && node tests/headerHamburger.test.cjs && node tests/changeLanguageColumns.test.cjs && node tests/cardsLoading.test.cjs && node tests/base64Chunk.test.cjs && node tests/backupPaths.test.cjs && node tests/backupCron.test.cjs && node tests/avatarUrlSafety.test.cjs && node tests/changeAvatarPopup.test.cjs && node tests/devOverlayRuntimeErrors.test.cjs && node tests/boardHeaderOneLine.test.cjs && node tests/securityReportScript.test.cjs && node tests/tablePage.test.cjs && node tests/leftMenu.test.cjs && node tests/boardsVisibilitySettings.test.cjs && node tests/snapMigrationSwitchOrder.test.cjs && node tests/importedUserReconciliationPlan.test.cjs && node tests/ldapPhoto.test.cjs && node tests/importedBoardMemberPlan.test.cjs && node tests/migrateNonFinite.test.cjs && node tests/addListComposerOptions.test.cjs && node tests/sidebarWidth.test.cjs && node tests/sidebarResize.test.cjs && node tests/securityMeifukun.test.cjs && node tests/securityLog.test.cjs && node tests/exporterBackpressure.test.cjs && node tests/ldapEmailFieldmap.test.cjs && node tests/listWidthDefaults.test.cjs && node tests/changelogCommitLinks.test.cjs && node tests/testsAreRegistered.test.cjs Line truncated
|
||||
"test:unit:node": "node tests/filenameSanitizer.test.cjs && node tests/cardBoardConsistency.test.cjs && node tests/cardUrl.test.cjs && node tests/defaultSwimlane.test.cjs && node tests/cardMoveModifier.test.cjs && node tests/authenticationMethod.test.cjs && node tests/linkedCardTarget.test.cjs && node tests/staleWhileRevalidate.test.cjs && node tests/restArrayParam.test.cjs && node tests/minicardLabelHeight.test.cjs && node tests/dateUtils.normalizeDigits.test.cjs && node tests/reconcileBoardTeamMembers.test.cjs && node tests/rulesBoardSelector.test.cjs && node tests/ruleActionResolve.test.cjs && node tests/boardBackground.test.cjs && node tests/weekStart.test.cjs && node tests/ldapUsernameSlug.test.cjs && node tests/ldapGroupAllowlist.test.cjs && node tests/ldapConnectionRelease.test.cjs && node tests/htmljsArrayContent.test.cjs && node tests/cardDescriptionDraft.test.cjs && node tests/commentDraft.test.cjs && node tests/attachmentDeleteGuard.test.cjs && node tests/ruleMoveAction.test.cjs && node tests/snapMigrationRecovery.test.cjs && node tests/migrationAttachmentExtraction.test.cjs && node tests/attachmentRepair.test.cjs && node tests/attachmentStoragePath.test.cjs && node tests/schemaUpgradeSteps.test.cjs && node tests/cpuExec.test.cjs && node tests/cpuExecWiring.test.cjs && node tests/ferretdbHasData.test.cjs && node tests/ferretdbPolling.test.cjs && node tests/ferretdbWaitTimeout.test.cjs && node tests/ferretdbOplog.test.cjs && node tests/ferretdbOplogReset.test.cjs && node tests/ferretdbTextDataBackup.test.cjs && node tests/recoveryPlan.test.cjs && node tests/recoveryReportQuery.test.cjs && node tests/recoveryEventsJsonl.test.cjs && node tests/recoveryReportWiring.test.cjs && node tests/recoveryMaintenance.test.cjs && node tests/importMemberMapping.test.cjs && node tests/boardMemberMapPlan.test.cjs && node tests/withDeadline.test.cjs && node tests/importVirtualMembers.test.cjs && node tests/sandstormMigrationBridge.test.cjs && node tests/fileNameDisplay.test.cjs && node tests/uploadFileName.test.cjs && node tests/diskSpace.test.cjs && node tests/fileTypeCorrection.test.cjs && node tests/fileHardeningGuards.test.cjs && node tests/cpuHighTracker.test.cjs && node tests/cpuMonitorWiring.test.cjs && node tests/buttonThemeColors.test.cjs && node tests/uiDensity.test.cjs && node tests/editorSubmitKey.test.cjs && node tests/isoWeek.test.cjs && node tests/boardCopyDefaults.test.cjs && node tests/linkedCardTitle.test.cjs && node tests/commentActivity.test.cjs && node tests/swimlaneSort.test.cjs && node tests/subtaskCopy.test.cjs && node tests/subtasksDefaultBoard.test.cjs && node tests/scrollbarCss.test.cjs && node tests/minicardBidiIsolation.test.cjs && node tests/notificationCleanup.test.cjs && node tests/cardSearch.test.cjs && node tests/linkedCardMembers.test.cjs && node tests/verificationEmail.test.cjs && node tests/boardSortReorder.test.cjs && node tests/checklistItemTitles.test.cjs && node tests/swimlaneFilter.test.cjs && node tests/popupOffset.test.cjs && node tests/popupAfterConfirm.test.cjs && node tests/defaultBoard.test.cjs && node tests/upcomingUiGuards.test.cjs && node tests/linkedCardCover.test.cjs && node tests/inviteEmailLanguage.test.cjs && node tests/domainTablePage.test.cjs && node tests/mongoSelectorSafety.test.cjs && node tests/filterDateNull.test.cjs && node tests/listMoveSwimlane.test.cjs && node tests/cardDragSwimlaneScrollRefresh.test.cjs && node tests/undoRedoSelection.test.cjs && node tests/softDelete.test.cjs && node tests/globalThemeColor.test.cjs && node tests/themeCategories.test.cjs && node tests/themeColorPicker.test.cjs && node tests/uiFonts.test.cjs && node tests/sandstormAutoOpen.test.cjs && node tests/createListParams.test.cjs && node tests/addBoardTileHeight.test.cjs && node tests/multiSelectionButton.test.cjs && node tests/headerHamburger.test.cjs && node tests/changeLanguageColumns.test.cjs && node tests/cardsLoading.test.cjs && node tests/base64Chunk.test.cjs && node tests/backupPaths.test.cjs && node tests/backupCron.test.cjs && node tests/avatarUrlSafety.test.cjs && node tests/changeAvatarPopup.test.cjs && node tests/devOverlayRuntimeErrors.test.cjs && node tests/boardHeaderOneLine.test.cjs && node tests/securityReportScript.test.cjs && node tests/tablePage.test.cjs && node tests/leftMenu.test.cjs && node tests/templateHandlersExist.test.cjs && node tests/boardsVisibilitySettings.test.cjs && node tests/snapMigrationSwitchOrder.test.cjs && node tests/importedUserReconciliationPlan.test.cjs && node tests/ldapPhoto.test.cjs && node tests/importedBoardMemberPlan.test.cjs && node tests/migrateNonFinite.test.cjs && node tests/addListComposerOptions.test.cjs && node tests/sidebarWidth.test.cjs && node tests/sidebarResize.test.cjs && node tests/securityMeifukun.test.cjs && node tests/securityLog.test.cjs && node tests/exporterBackpressure.test.cjs && node tests/ldapEmailFieldmap.test.cjs && node tests/listWidthDefaults.test.cjs && node tests/changelogCommitLinks.test.cLine truncated
|
||||
"test:unit:all": "npm run test:unit:node && node tests/cards.stickers.test.js && node tests/stickers.test.js && node tests/stickers.packs.test.js && node tests/linkCardPopup.test.js && node tests/trelloCreator.import.test.js && node tests/trelloImport.maplink.test.js && node tests/trelloImport.zip.test.js && node tests/wekanCreator.import.test.js && node tests/wekanCreator.inconsistent.test.js && node tests/unit/oauth2-admin-groups.test.js",
|
||||
"test:watch": "meteor test --driver-package meteortesting:mocha",
|
||||
"test:e2e": "node tests/e2e/list-regressions.js",
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
'use strict';
|
||||
|
||||
// Every Template.X.events / helpers / onCreated / onRendered / onDestroyed must
|
||||
// have a matching `template(name="X")` in some .jade file.
|
||||
//
|
||||
// This is not a style rule. Registering a handler on a template that does not
|
||||
// exist throws at MODULE LOAD:
|
||||
//
|
||||
// TypeError: can't access property "events", Template.accountSettings is undefined
|
||||
//
|
||||
// and because it throws, every module after it in the client graph never runs. A
|
||||
// removed Admin Panel pane therefore took out `client/features/users.js`, so
|
||||
// passwordInput.jade was never registered and useraccounts logged
|
||||
// "Warning no template passwordInput found!" - the password fields disappeared
|
||||
// from /sign-in and /sign-up. One dead reference in the Admin Panel locked users
|
||||
// out of the login form.
|
||||
//
|
||||
// Nothing else catches this: the file parses, the tests pass, and the failure only
|
||||
// appears in a browser console.
|
||||
//
|
||||
// Run: node tests/templateHandlersExist.test.cjs
|
||||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
let passed = 0;
|
||||
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
||||
|
||||
const root = path.join(__dirname, '..');
|
||||
|
||||
function walk(dir, out = { jade: [], js: [] }) {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) walk(full, out);
|
||||
else if (full.endsWith('.jade')) out.jade.push(full);
|
||||
else if (full.endsWith('.js')) out.js.push(full);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
const files = walk(path.join(root, 'client/components'));
|
||||
|
||||
// Templates defined in markup, plus the ones Blaze/packages provide that app code
|
||||
// legitimately extends.
|
||||
const defined = new Set(['body']);
|
||||
for (const file of files.jade) {
|
||||
const src = fs.readFileSync(file, 'utf8');
|
||||
for (const m of src.matchAll(/template\(name=['"]([\w]+)['"]\)/g)) defined.add(m[1]);
|
||||
}
|
||||
// Templates that come from packages (useraccounts, etc.) rather than our jade.
|
||||
const fromPackages = new Set(['atForm', 'atSigninLink', 'atSignupLink', 'atPwdForm',
|
||||
'atPwdFormBtn', 'atInput', 'atTitle', 'atError', 'atResult', 'atSocial', 'atOauth',
|
||||
'userFormsLayout']);
|
||||
|
||||
console.log('templateHandlersExist:');
|
||||
|
||||
test('every template handler targets a template that exists', () => {
|
||||
const missing = [];
|
||||
for (const file of files.js) {
|
||||
// Strip comments: a commented-out Template.cards.events() in minicard.js is
|
||||
// not a registration and must not be reported as one.
|
||||
const src = fs.readFileSync(file, 'utf8')
|
||||
.replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
.replace(/^\s*\/\/.*$/gm, '');
|
||||
for (const m of src.matchAll(/Template\.(\w+)\.(events|helpers|onCreated|onRendered|onDestroyed)\(/g)) {
|
||||
const [, name, hook] = m;
|
||||
if (defined.has(name) || fromPackages.has(name)) continue;
|
||||
missing.push(`${path.relative(root, file)}: Template.${name}.${hook}()`);
|
||||
}
|
||||
}
|
||||
assert.deepStrictEqual(missing, [],
|
||||
'these would throw at module load and abort every module after them:\n ' +
|
||||
missing.join('\n '));
|
||||
});
|
||||
|
||||
test('the pane removed from Admin Panel Settings left nothing behind', () => {
|
||||
// The specific regression: accountSettings was removed when its three settings
|
||||
// moved to Email and Login.
|
||||
const js = fs.readFileSync(path.join(root, 'client/components/settings/settingBody.js'), 'utf8');
|
||||
const jade = fs.readFileSync(path.join(root, 'client/components/settings/settingBody.jade'), 'utf8');
|
||||
assert.ok(!/template\(name=['"]accountSettings['"]\)/.test(jade),
|
||||
'the pane is gone');
|
||||
assert.ok(!/Template\.accountSettings\.(events|helpers|onCreated|onRendered)/.test(js),
|
||||
'and nothing may still register on it');
|
||||
// Its save button moved to the template that renders the Login pane.
|
||||
assert.ok(/Template\.setting\.events\(\{[\s\S]*js-account-access-save/.test(js),
|
||||
'the save handler belongs to the template that renders the pane');
|
||||
});
|
||||
|
||||
console.log(`\ntemplateHandlersExist: ${passed} tests passed`);
|
||||
Reference in new issue
Block a user