@ladjs/web 18.0.1 → 18.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +27 -27
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -329,33 +329,6 @@ class Web {
329
329
  const stateHelper = new StateHelper(this.config.views.locals);
330
330
  app.use(stateHelper.middleware);
331
331
 
332
- // add specific locals
333
- app.use((ctx, next) => {
334
- // passport-related helpers (e.g. for rendering log in with X buttons)
335
- ctx.state.passport = ctx.passport ? {} : false;
336
- if (
337
- ctx.passport &&
338
- ctx.passport.config &&
339
- ctx.passport.config.providers
340
- ) {
341
- for (const key of Object.keys(ctx.passport.config.providers)) {
342
- ctx.state.passport[key] = boolean(ctx.passport.config.providers[key]);
343
- }
344
- }
345
-
346
- // add limited `ctx` object to the state for views
347
- ctx.state.ctx = {};
348
- ctx.state.ctx.get = ctx.get.bind(ctx);
349
- ctx.state.ctx.locale = ctx.locale;
350
- ctx.state.ctx.path = ctx.path;
351
- ctx.state.ctx.pathWithoutLocale = ctx.pathWithoutLocale;
352
- ctx.state.ctx.query = ctx.query;
353
- ctx.state.ctx.sessionId = ctx.sessionId;
354
- ctx.state.ctx.url = ctx.url;
355
-
356
- return next();
357
- });
358
-
359
332
  // session store
360
333
  app.keys = this.config.sessionKeys;
361
334
  app.use(
@@ -417,6 +390,33 @@ class Web {
417
390
  app.use(this.passport.session());
418
391
  }
419
392
 
393
+ // add specific locals
394
+ app.use((ctx, next) => {
395
+ // passport-related helpers (e.g. for rendering log in with X buttons)
396
+ ctx.state.passport = ctx.passport ? {} : false;
397
+ if (
398
+ ctx.passport &&
399
+ ctx.passport.config &&
400
+ ctx.passport.config.providers
401
+ ) {
402
+ for (const key of Object.keys(ctx.passport.config.providers)) {
403
+ ctx.state.passport[key] = boolean(ctx.passport.config.providers[key]);
404
+ }
405
+ }
406
+
407
+ // add limited `ctx` object to the state for views
408
+ ctx.state.ctx = {};
409
+ ctx.state.ctx.get = ctx.get.bind(ctx);
410
+ ctx.state.ctx.locale = ctx.locale;
411
+ ctx.state.ctx.path = ctx.path;
412
+ ctx.state.ctx.pathWithoutLocale = ctx.pathWithoutLocale;
413
+ ctx.state.ctx.query = ctx.query;
414
+ ctx.state.ctx.sessionId = ctx.sessionId;
415
+ ctx.state.ctx.url = ctx.url;
416
+
417
+ return next();
418
+ });
419
+
420
420
  // rate limiting
421
421
  if (this.client && this.config.rateLimit)
422
422
  app.use(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ladjs/web",
3
3
  "description": "Web server for Lad",
4
- "version": "18.0.1",
4
+ "version": "18.0.2",
5
5
  "author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/ladjs/web/issues",