Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use express() instead of express.Router() #604

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion middleware/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const enforceLeadingSlash = (path) => {
const auth = function (params) {
const config = getConfig(params);
debug('configuration object processed, resulting configuration: %O', config);
const router = new express.Router();
const router = new express();
const transient = new TransientCookieHandler(config);

router.use(appSession(config));
Expand Down
20 changes: 12 additions & 8 deletions test/login.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ describe('auth', () => {
it('should contain the default authentication routes', async () => {
const router = auth(defaultConfig);
server = await createServer(router);
assert.ok(router.stack.some(filterRoute('GET', '/login')));
assert.ok(router.stack.some(filterRoute('GET', '/logout')));
assert.ok(router.stack.some(filterRoute('POST', '/callback')));
assert.ok(router.stack.some(filterRoute('GET', '/callback')));
assert.ok(router._router.stack.some(filterRoute('GET', '/login')));
assert.ok(router._router.stack.some(filterRoute('GET', '/logout')));
assert.ok(router._router.stack.some(filterRoute('POST', '/callback')));
assert.ok(router._router.stack.some(filterRoute('GET', '/callback')));
});

it('should contain custom authentication routes', async () => {
Expand All @@ -79,10 +79,14 @@ describe('auth', () => {
},
});
server = await createServer(router);
assert.ok(router.stack.some(filterRoute('GET', '/custom-login')));
assert.ok(router.stack.some(filterRoute('GET', '/custom-logout')));
assert.ok(router.stack.some(filterRoute('POST', '/custom-callback')));
assert.ok(router.stack.some(filterRoute('GET', '/custom-callback')));
assert.ok(router._router.stack.some(filterRoute('GET', '/custom-login')));
assert.ok(router._router.stack.some(filterRoute('GET', '/custom-logout')));
assert.ok(
router._router.stack.some(filterRoute('POST', '/custom-callback'))
);
assert.ok(
router._router.stack.some(filterRoute('GET', '/custom-callback'))
);
});

it('should redirect to the authorize url for /login', async () => {
Expand Down
Loading