Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #10 Default signedness based on presence of keys

  • Loading branch information...
commit b1322b6a7b5dc75a5a7d7662c99de65943cee01e 1 parent d55bf43
@isaacs authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/cookies.js
View
8 lib/cookies.js
@@ -10,6 +10,7 @@ Cookies.prototype = {
get: function( name, opts ) {
var sigName = name + ".sig"
, header, match, value, remote, data, index
+ , signed = opts && opts.signed !== undefined ? opts.signed : !!this.keys
header = this.request.headers[ "cookie" ]
if ( !header ) return
@@ -18,7 +19,7 @@ Cookies.prototype = {
if ( !match ) return
value = match[ 1 ]
- if ( !opts || !opts.signed ) return value
+ if ( !opts || !signed ) return value
remote = this.get( sigName )
if ( !remote ) return
@@ -41,6 +42,7 @@ Cookies.prototype = {
, secure = res.socket ? res.socket.encrypted || req.connection.proxySecure : req.connection.proxySecure
, cookie = new Cookie( name, value, opts )
, header
+ , signed = opts && opts.signed !== undefined ? opts.signed : !!this.keys
if ( typeof headers == "string" ) headers = [ headers ]
@@ -50,7 +52,7 @@ Cookies.prototype = {
if (opts && "secure" in opts) cookie.secure = opts.secure
headers.push( cookie.toHeader() )
- if ( opts && opts.signed ) {
+ if ( opts && signed ) {
cookie.value = this.keys.sign( cookie.toString() )
cookie.name += ".sig"
headers.push( cookie.toHeader() )
@@ -109,4 +111,4 @@ Cookies.connect = Cookies.express = function(keys) {
}
}
-module.exports = Cookies
+module.exports = Cookies
Please sign in to comment.
Something went wrong with that request. Please try again.