Files
wekan/tests/emailVerificationRoute.test.cjs
T
Lauri Ojansivu bb267fddf4 Restore anonymous email verification links
Configure the maintained accounts package's verification route so generated links reach /verify-email/:token and consume the token instead of falling through to WeKan's signed-in guard. Also expose the companion resend route. Add positive and negative wiring coverage plus live Chromium cases proving valid links verify, consume, and sign in while invalid tokens do none of those.

Thanks to Sunildevb, jgrocha, nickian, bbyszio, teutat3s, MichaelW-SD, alessiozanutta, mbalmer, Ranzo, DarthJahus, AndreLCRodrigues and xet7 !

Fixes #1426,
2026-08-25 18:46:03 +03:00

51 lines
1.5 KiB
JavaScript

'use strict';
// Route wiring regression for #1426. The accounts package does not install its
// token consumer merely because sendVerificationEmail is enabled; WeKan must
// explicitly configure the verifyEmail route.
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const source = fs.readFileSync(
path.join(__dirname, '..', 'config/accounts.js'),
'utf8',
);
let passed = 0;
function test(name, fn) {
fn();
passed += 1;
console.log(' ok -', name);
}
test('verification email sending remains enabled', () => {
assert.match(source, /sendVerificationEmail:\s*true/);
});
test('the token consumer and resend routes are configured', () => {
const routeStart = source.lastIndexOf("[\n 'signIn'");
const routeList = source.slice(
routeStart,
source.indexOf(
"].forEach(routeName => AccountsTemplates.configureRoute(routeName));",
routeStart,
) + 80,
);
assert.match(routeList, /'verifyEmail'/);
assert.match(routeList, /'resendVerificationEmail'/);
assert.match(routeList, /AccountsTemplates\.configureRoute\(routeName\)/);
});
test('verification is not protected by WeKan signed-in route guards', () => {
const router = fs.readFileSync(
path.join(__dirname, '..', 'config/router.js'),
'utf8',
);
assert.doesNotMatch(router, /verify-email/,
'the accounts package owns the anonymous token route; do not shadow it');
});
console.log(`\nemailVerificationRoute: ${passed} tests passed`);