koa-generic-session
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -237,4 +237,20 @@ 'use strict'; | ||
ctx.saveSession = (() => { | ||
var _ref5 = _asyncToGenerator(function* () { | ||
const result = yield getSession(ctx); | ||
if (!result) { | ||
return next(); | ||
} | ||
return refreshSession(ctx, ctx.session, result.originalHash, result.isNew); | ||
}); | ||
function saveSession() { | ||
return _ref5.apply(this, arguments); | ||
} | ||
return saveSession; | ||
})(); | ||
ctx.regenerateSession = (() => { | ||
var _ref5 = _asyncToGenerator(function* () { | ||
var _ref6 = _asyncToGenerator(function* () { | ||
debug('regenerating session'); | ||
@@ -256,3 +272,3 @@ if (!result.isNew) { | ||
function regenerateSession() { | ||
return _ref5.apply(this, arguments); | ||
return _ref6.apply(this, arguments); | ||
} | ||
@@ -298,3 +314,3 @@ | ||
let deferSession = (() => { | ||
var _ref6 = _asyncToGenerator(function* (ctx, next) { | ||
var _ref7 = _asyncToGenerator(function* (ctx, next) { | ||
ctx.sessionStore = store; | ||
@@ -352,4 +368,23 @@ | ||
ctx.saveSession = (() => { | ||
var _ref8 = _asyncToGenerator(function* () { | ||
// make sure that the session has been loaded | ||
yield ctx.session; | ||
const result = yield getSession(ctx); | ||
if (!result) { | ||
return next(); | ||
} | ||
return refreshSession(ctx, ctx.session, result.originalHash, result.isNew); | ||
}); | ||
function saveSession() { | ||
return _ref8.apply(this, arguments); | ||
} | ||
return saveSession; | ||
})(); | ||
ctx.regenerateSession = (() => { | ||
var _ref7 = _asyncToGenerator(function* () { | ||
var _ref9 = _asyncToGenerator(function* () { | ||
debug('regenerating session'); | ||
@@ -374,3 +409,3 @@ // make sure that the session has been loaded | ||
function regenerateSession() { | ||
return _ref7.apply(this, arguments); | ||
return _ref9.apply(this, arguments); | ||
} | ||
@@ -394,3 +429,3 @@ | ||
return function deferSession(_x11, _x12) { | ||
return _ref6.apply(this, arguments); | ||
return _ref7.apply(this, arguments); | ||
}; | ||
@@ -397,0 +432,0 @@ })(); |
@@ -5,3 +5,3 @@ { | ||
"repository": "koajs/generic-session", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "engines": { |
@@ -93,2 +93,3 @@ generic-session | ||
* Calling `this.regenerateSession` will destroy any existing session and generate a new, empty one in its place. The new session will have a different ID. | ||
* Calling `this.saveSession` will save an existing session (this method was added for [koa-redirect-loop](https://github.com/niftylettuce/koa-redirect-loop)) | ||
* Setting `this.sessionSave = true` will force saving the session regardless of any other options or conditions. | ||
@@ -95,0 +96,0 @@ * Setting `this.sessionSave = false` will prevent saving the session regardless of any other options or conditions. |
35082
577
171