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

Fix incorrect import of requiresAuth #118

Merged
merged 1 commit into from
Jul 22, 2020
Merged
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 @@ -5,7 +5,7 @@ const createError = require('http-errors');
const debug = require('../lib/debug');
const { get: getConfig } = require('../lib/config');
const { get: getClient } = require('../lib/client');
const requiresAuth = require('./requiresAuth');
const { requiresAuth } = require('./requiresAuth');
const TransientCookieHandler = require('../lib/transientHandler');
const { RequestContext, ResponseContext } = require('../lib/context');
const appSession = require('../lib/appSession');
Expand Down
14 changes: 14 additions & 0 deletions test/login.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ describe('auth', () => {
assert.equal(getCookieFromResponse(res, 'state'), parsed.query.state);
});

it('should redirect to the authorize url for any route if authRequired', async () => {
server = await createServer(
auth({
...defaultConfig,
authRequired: true,
})
);
const res = await request.get('/session', {
baseUrl,
followRedirect: false,
});
assert.equal(res.statusCode, 302);
});

it('should redirect to the authorize url for /login in code flow', async () => {
server = await createServer(
auth({
Expand Down