]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/commitdiff
store stringified objects in redis for now
authorJohannes Zellner <johannes@cloudron.io>
Thu, 9 Feb 2017 13:47:47 +0000 (14:47 +0100)
committerJohannes Zellner <johannes@cloudron.io>
Thu, 9 Feb 2017 13:47:47 +0000 (14:47 +0100)
src/auth.js

index 09ec8b79738ddd1f565e68147cde62ac4cf64f91..0338632890c55d2cac86e0c6c7c395ec65db4d80 100644 (file)
@@ -39,8 +39,14 @@ if (process.env.REDIS_URL) {
     }
 
     // overwrite the tokenStore api
-    tokenStore.get = redisClient.get.bind(redisClient);
-    tokenStore.set = redisClient.set.bind(redisClient);
+    tokenStore.get = function (token, callback) {
+        redisClient.get(token, function (error, result) {
+            callback(error || null, safe.JSON.parse(result));
+        });
+    };
+    tokenStore.set = function (token, data, callback) {
+        redisClient.set(token, JSON.stringify(data), callback);
+    };
     tokenStore.del = redisClient.del.bind(redisClient);
 } else {
     console.log('Use in-memory token store');