mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
Add some sources to the unsign method
This commit is contained in:
parent
21dffa73f0
commit
339c23a64e
1 changed files with 5 additions and 1 deletions
|
@ -12,7 +12,9 @@ var pako = require('pako');
|
|||
*/
|
||||
var Jar = {
|
||||
unsign: function (value, callback) {
|
||||
// Return the usable content portion of a signed, compressed cookie
|
||||
// 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');
|
||||
try {
|
||||
var b64Data = value.split(':')[0];
|
||||
|
@ -23,6 +25,8 @@ var Jar = {
|
|||
}
|
||||
|
||||
// Django makes its base64 strings url safe by replacing + and / with - and _ respectively
|
||||
// using base64.urlsafe_b64encode
|
||||
// https://docs.python.org/2/library/base64.html#base64.b64encode
|
||||
b64Data = b64Data.replace(/[-_]/g, function (c) {return {'-':'+', '_':'/'}[c]; });
|
||||
var strData = atob(b64Data);
|
||||
|
||||
|
|
Loading…
Reference in a new issue