Skip to content

Commit

Permalink
Fix incorrect import of requiresAuth (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjmcgrath committed Aug 13, 2020
1 parent e1c1c3b commit e1d1e55
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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

0 comments on commit e1d1e55

Please sign in to comment.