koa-redirect-loop
Advanced tools
Comparing version 2.0.4 to 2.0.5
20
index.js
@@ -24,8 +24,20 @@ const Url = require('url-parse'); | ||
async middleware(ctx, next) { | ||
if (!ctx.session) throw new Error('Sessions required'); | ||
if (typeof ctx.saveSession !== 'function') | ||
throw new Error( | ||
'Please use koa-generic-session v2.0.3+ which exposes a `ctx.saveSession()` method' | ||
if (!ctx.session) { | ||
config.logger.error( | ||
new Error( | ||
'ctx.session missing, sessions required for koa-redirect-loop' | ||
) | ||
); | ||
return next(); | ||
} | ||
if (typeof ctx.saveSession !== 'function') { | ||
config.logger.error( | ||
new Error( | ||
'Please use koa-generic-session v2.0.3+ which exposes a `ctx.saveSession()` method' | ||
) | ||
); | ||
return next(); | ||
} | ||
const { config } = this; | ||
@@ -32,0 +44,0 @@ const { redirect } = ctx; |
{ | ||
"name": "koa-redirect-loop", | ||
"description": "Prevent redirect loops with sessions since HTTP referrer header is unreliable and ensures sessions are saved upon redirect", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
@@ -6,0 +6,0 @@ "ava": { |
9049
111