Commit 794c3e2c authored by Matthew Taylor's avatar Matthew Taylor

Set null contents to null instead of error throw

Before, if a cookie didn't exist, it would throw an error, not causing permissions/tokens to change to empty values. This fixes that (and #626) by setting the value to undefined instead.
parent 4ef6b22b
......@@ -15,7 +15,8 @@ var Jar = {
// Return the usable content portion of a signed, compressed cookie generated by
// Django's signing module
// https://github.com/django/django/blob/stable/1.8.x/django/core/signing.py
if (!value) return callback('No value to unsign');
if (typeof value === 'undefined') return callback(null, value);
try {
var b64Data = value.split(':')[0];
var decompress = false;
......@@ -80,6 +81,8 @@ var Jar = {
if (err) return callback(err);
Jar.unsign(value, function (err, contents) {
if (err) return callback(err);
if (typeof contents === 'undefined') return callback(null, contents);
try {
var data = JSON.parse(contents);
} catch (err) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment