mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
fix tests that require session authentication
This commit is contained in:
@@ -10,10 +10,14 @@ import nconf from 'nconf';
|
||||
import morgan from 'morgan';
|
||||
import responseHandler from './response';
|
||||
import setupBody from './setupBody';
|
||||
import cookieSession from 'cookie-session';
|
||||
|
||||
const IS_PROD = nconf.get('IS_PROD');
|
||||
const DISABLE_LOGGING = nconf.get('DISABLE_REQUEST_LOGGING');
|
||||
|
||||
const SESSION_SECRET = nconf.get('SESSION_SECRET');
|
||||
const TWO_WEEKS = 1000 * 60 * 60 * 24 * 14;
|
||||
|
||||
export default function attachMiddlewares (app) {
|
||||
if (!IS_PROD && !DISABLE_LOGGING) app.use(morgan('dev'));
|
||||
|
||||
@@ -22,6 +26,12 @@ export default function attachMiddlewares (app) {
|
||||
extended: true, // Uses 'qs' library as old connect middleware
|
||||
}));
|
||||
app.use(bodyParser.json());
|
||||
app.use(cookieSession({
|
||||
name: 'connect:sess', // Used to keep backward compatibility with Express 3 cookies
|
||||
secret: SESSION_SECRET,
|
||||
httpOnly: false, // TODO this should be true for security, what about https only?
|
||||
maxAge: TWO_WEEKS,
|
||||
}));
|
||||
app.use(expressValidator());
|
||||
app.use(analytics);
|
||||
app.use(setupBody);
|
||||
|
||||
Reference in New Issue
Block a user