- Add credentialManager, totpConfig, saveTotpConfig, session to deps - Create ctx shim for backward compatibility - Fix hasOwnProperty anti-pattern (use Object.prototype.hasOwnProperty.call) Result: 54 errors → 0 errors
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
const express = require('express');
|
|
const initTotp = require('./totp');
|
|
const initKeys = require('./keys');
|
|
const initSessionHandlers = require('./session-handlers');
|
|
const initSsoGate = require('./sso-gate');
|
|
|
|
/**
|
|
* Auth routes aggregator
|
|
* Assembles all auth sub-routes with their dependencies
|
|
* @param {Object} ctx - Application context (for backward compatibility)
|
|
* @returns {express.Router}
|
|
*/
|
|
module.exports = function(ctx) {
|
|
const router = express.Router();
|
|
|
|
// Extract dependencies from context
|
|
const deps = {
|
|
authManager: ctx.authManager,
|
|
credentialManager: ctx.credentialManager,
|
|
totpConfig: ctx.totpConfig,
|
|
saveTotpConfig: ctx.saveTotpConfig,
|
|
session: ctx.session,
|
|
asyncHandler: ctx.asyncHandler,
|
|
errorResponse: ctx.errorResponse,
|
|
log: ctx.log
|
|
};
|
|
|
|
const { getAppSession, appSessionCache } = initSessionHandlers(deps);
|
|
|
|
router.use(initTotp(deps));
|
|
router.use(initKeys(deps));
|
|
router.use(initSsoGate({ ...deps, getAppSession, appSessionCache }));
|
|
|
|
return router;
|
|
};
|