mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
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.
This commit is contained in:
parent
4ef6b22b05
commit
794c3e2cba
1 changed files with 4 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue