From aa4afd0327a223c6ff842131d08e15f9a6e8530e Mon Sep 17 00:00:00 2001 From: Stephan Jauernick Date: Thu, 6 Dec 2012 21:03:15 +0100 Subject: [PATCH 1/5] Update src/node/db/API.js Added a checkToken method for checking if the API token is valid. --- src/node/db/API.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/node/db/API.js b/src/node/db/API.js index 4979e8c65..18ed1d0c5 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -548,6 +548,18 @@ exports.sendClientsMessage = function (padID, msg, callback) { } ); } +/** +checkToken() returns ok when api token is valid + +Example returns: + +{code: 0, message:"ok"} +*/ +exports.checkToken = function(padID, callback) +{ + callback() +} + /******************************/ /** INTERNAL HELPER FUNCTIONS */ From da75f26aeb67610556d13b13cedbfedb267036e8 Mon Sep 17 00:00:00 2001 From: Stephan Jauernick Date: Thu, 6 Dec 2012 21:06:09 +0100 Subject: [PATCH 2/5] Update src/node/handler/APIHandler.js Added the checkToken function to the function array. --- src/node/handler/APIHandler.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/node/handler/APIHandler.js b/src/node/handler/APIHandler.js index f99762cea..198ec97b3 100644 --- a/src/node/handler/APIHandler.js +++ b/src/node/handler/APIHandler.js @@ -68,6 +68,7 @@ var version = , "isPasswordProtected" : ["padID"] , "listAuthorsOfPad" : ["padID"] , "padUsersCount" : ["padID"] + , "checkToken" : [] } , "1.1": { "createGroup" : [] @@ -102,6 +103,7 @@ var version = , "padUsers" : ["padID"] , "sendClientsMessage" : ["padID", "msg"] , "listAllGroups" : [] + , "checkToken" : [] } }; From eaba7095d5230acf38daec28db931554bf1c323b Mon Sep 17 00:00:00 2001 From: Stephan Jauernick Date: Thu, 6 Dec 2012 21:24:44 +0100 Subject: [PATCH 3/5] Update src/node/db/API.js Added a missing symicolon and removed the padID argument which is not passed(and thus leads to an errors because the callback lands in there). --- src/node/db/API.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/db/API.js b/src/node/db/API.js index 18ed1d0c5..783cf97f2 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -555,9 +555,9 @@ Example returns: {code: 0, message:"ok"} */ -exports.checkToken = function(padID, callback) +exports.checkToken = function(callback) { - callback() + callback(); } From f072d940e0fde22988ca1cd7c47ac172bbbdc755 Mon Sep 17 00:00:00 2001 From: Stephan Jauernick Date: Thu, 6 Dec 2012 21:26:51 +0100 Subject: [PATCH 4/5] Update src/node/db/API.js Corrected function documentation. --- src/node/db/API.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node/db/API.js b/src/node/db/API.js index 783cf97f2..ea58d8599 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -553,7 +553,8 @@ checkToken() returns ok when api token is valid Example returns: -{code: 0, message:"ok"} +{"code":0,"message":"ok","data":null} +{"code":4,"message":"no or wrong API Key","data":null} */ exports.checkToken = function(callback) { From f5814b8bf7548a1854cecfe73522ecf362aabd42 Mon Sep 17 00:00:00 2001 From: Stephan Jauernick Date: Thu, 6 Dec 2012 21:33:22 +0100 Subject: [PATCH 5/5] Update doc/api/http_api.md Added docs for the checkToken function --- doc/api/http_api.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/api/http_api.md b/doc/api/http_api.md index 990d1b498..541324d20 100644 --- a/doc/api/http_api.md +++ b/doc/api/http_api.md @@ -407,3 +407,12 @@ sends a custom message of type `msg` to the pad *Example returns:* * `{code: 0, message:"ok", data: {}}` * `{code: 1, message:"padID does not exist", data: null}` + +#### checkToken() + * API >= 1 + +returns ok when api token is valid + +*Example returns:* + * `{"code":0,"message":"ok","data":null}` + * `{"code":4,"message":"no or wrong API Key","data":null}`